scanf character 12-20-2012, 05:43 PM
#1
Guys, I have this strange problem in C, I can't figure out the problem. I want to make a small calculator and it is like this:
The rest are switch statement for each operator.
After I compiled and run it, it just skips the scanf statement for variable 'op' and goes on to scanf for value b. like this:
a= 56
op[+,-,*,/,%]= b=
...
Thanks.
:epic:
Code:
float a,b,total;
char op;
printf("a= ");scanf("%f",&a);
printf("op[+,-,*,/,%]= ");scanf("%c",&op);
printf("b= ");scanf("%f",&b);After I compiled and run it, it just skips the scanf statement for variable 'op' and goes on to scanf for value b. like this:
a= 56
op[+,-,*,/,%]= b=
...
Thanks.
:epic:


![[+]](https://sinister.li/images/modern/collapse_collapsed.png)
![[Image: fow57.jpg]](http://i.imgur.com/fow57.jpg)


![[Image: 2YpkRjy.png]](http://i.imgur.com/2YpkRjy.png)