#include <stdio.h>
#include <stdlib.h>
void main(){
char elevador;
int cod=0, a=0, b=0, c=0;
while(cod == 0){
printf("\nElevador utilizado (a/b/c)? ");
scanf("%c", &elevador);
switch(elevador){
case 'a':
a++;
break;
case 'b':
b++;
break;
case 'c':
c++;
break;
default:
printf("opcao inválida!");
}
}
}
When I use the data type char
and I use the scanf()
do I need to give a space after the first quote?
In this way:
scanf ("% c", & elevator); < < Space after "_% c"
Well, if you do not use my program as code in the beginning will work "abnormal" can test, it will run like this: