|
-
October 18th, 1999, 07:28 AM
#1
correction
whoops, i made a mistake in the other post- its not that char ans generates an error, its just that it doesnt work in the loop. its supposed to quit when ans doesnt equal y, but even when i specifically type in 'n' the loop doesnt stop.
-
October 18th, 1999, 07:52 AM
#2
Re: correction
Make sure you flush the keyboard first, otherwise you may be getting some characters that you do not want.
-
October 18th, 1999, 09:38 AM
#3
Re: correction
'flush the keyboard'? what is that, how do you do it?
-
October 18th, 1999, 09:43 AM
#4
Re: correction
There is a C call, fflush(FILE *) that you can use.
fflush(stdin);
Or just use your own.
while ( getchar() != '\n' );
By doing what you are doing, you are assuming that the keyboard buffer is empty. And many times it is not.
Just call one of these routines before you try to get any keyboard data.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|