N
Neil
Hello
Just to let you know this not homework, I'm learning the language of C
on my own time..
I recently tried to create a escape for user saying
printf ("Do you want to continue? (y or n)");
The scanf statement follows the prompt(printf above) which is the last
statement in the while loop, before the "}"
This scanf statement doesn't work!!
scanf("%c", &answer); //answer is declared as char....OK
When I run the debugger in Turbo C++, it goes rate on by, and doesn't
stop to ask the user to enter a char 'y' or 'n'.......I spent an hour
trying to hault the program at the scanf statement.
What's going on here?
Then I tried this statement.........
scanf("\n%c", &answer); //Works!!, but I don't know why?
Can someone tell me? please..
-Neil
Thanks for all your help
Just to let you know this not homework, I'm learning the language of C
on my own time..
I recently tried to create a escape for user saying
printf ("Do you want to continue? (y or n)");
The scanf statement follows the prompt(printf above) which is the last
statement in the while loop, before the "}"
This scanf statement doesn't work!!
scanf("%c", &answer); //answer is declared as char....OK
When I run the debugger in Turbo C++, it goes rate on by, and doesn't
stop to ask the user to enter a char 'y' or 'n'.......I spent an hour
trying to hault the program at the scanf statement.
What's going on here?
Then I tried this statement.........
scanf("\n%c", &answer); //Works!!, but I don't know why?
Can someone tell me? please..
-Neil
Thanks for all your help