Learning C - please help

Pages: 12
This is what happens if i use %c, it looks like it doesn't follow the if-else if mechanics.

Seams after the do while loop is finished it just skips first scanf, does the else if part and then the 2nd scanf works resulting in:

Welcome to Ironman receipt calculator

(0)to close
ItemPrice: 10.25
ItemPrice: 10.25
ItemPrice: 0
Total cost: 20.50$

Open new receipt? y/n Invalid input, try again!
Open new receipt? y/n y
(0)to close
Last edited on
Yes, this is exactly the expected output if you're using scanf("%c", &choice);. As mentioned earlier in this thread, your intention was most likely to use scanf(" %c", &choice);.
If your textbook doesn't explain what the space character does in scanf, it probably misses on a lot of other C basics.
Indeed, it worked after i tried out what you guyz said i should do. In previous post i was just replying to freddie's question.

By the way IronmanCro, I just tried your program with %c instead of %s 
and far as I could tell it worked normally. 
That doesn't really mean it wasn't acting up for you though. 
What was it doing that was abnormal with %c (if you are still following your thread)? 
Last edited on
ok after every "printf" use the centence "fflush(stdout);"

#include <stdio.h>
int main (){
itn a;
printf ("put something");
printf ("you type %d\n",a)
return 0}
the problem is only in the eclipse, if you run your program in the windows terminal worcs fine

Topic archived. No new replies allowed.
Pages: 12