2
#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!");
}
}
}
Why when I use the data type char
and use the scanf()
I need to make room after the first quotation marks?
In this way:
scanf(" %c", &lift); << Space after "_%c"
Because if you do not use my program as code at the beginning will work in an "abnormal" way you can test, it will run this way:
Thanks again. The other topic helps me understand better. .
– WSS