|
-
December 10th, 2002, 09:12 PM
#1
gets() input statement
Why is it that sometimes, my program does not ask the user for input even if I have used gets();
Thanks, Shilpi
-
December 11th, 2002, 04:22 AM
#2
If I remember well, gets returns when the user presses the 'Enter' key.
If for whatever reason, the user double-presses this key at the end of the previous thing he was doing, then gets might return with an empty string, and that look as if nothing was asked to the user.
Elrond
A chess genius is a human being who focuses vast, little-understood mental gifts and labors on an ultimately trivial human enterprise.
-- George Steiner
-
December 11th, 2002, 10:24 AM
#3
Nope I didn't press the enter key twice in any of the previous queries, but do you think having a cprintf statment or cout statement with "\n" before gets would matter?
Shilpi
-
December 11th, 2002, 10:30 AM
#4
Try removing the \n from the previous statement and see how it goes, but I don't think that's the problem.
Elrond
A chess genius is a human being who focuses vast, little-understood mental gifts and labors on an ultimately trivial human enterprise.
-- George Steiner
-
December 12th, 2002, 12:23 AM
#5
I also faced the same problem sometime back...If I remember it correctly then I used flush() before making a call to gets so that the buffer will be empty and that worked in my case.
U can also try the same...
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
|