jeudi 26 février 2015

C - Why am I getting two characters excpet one as output?



So I create this small program to represent my problem. Run program enter 'a' press ENTER.


C Code:



#include <stdio.h>
#include <stdlib.h>

int main(void)
{
char o;
while(1)
{
printf("> ");
scanf("%c",&o);
switch(o)
{
case 'a' :
printf("%c\n",o);
break;
case 'q' :
return 0;
}
}
}


Output is:



> a
a
> > *(waiting for imput)*


What I expected it to be:



> a
a
> *(waiting for imput)*


Please give me some advice how to get my problem solved. Thank you.




Aucun commentaire:

Enregistrer un commentaire