Thursday, July 30, 2009

Why is the gets() in C does not function in my program?

is it due to the compiler or what? if ever, what shall i do so it can function on my program?thanks

Why is the gets() in C does not function in my program?
Hi,


One reason for gets() to not work properly is the stdin buffer. stdin is standard input device, which is keyboard. When we execute program and provide input through the keyboard, the buffer is utilized for storing the keystrokes temporarily.


Try fflush(stdin); before gets(). This instruction clears the buffer for stdin and allows user to enter new keystrokes, meant to go in gets().


Hope this work outs, else, u can post the code...
Reply:in C++, get() is defined in the istream header file..





You probably need to supply this at the top.
Reply:please post the portion of the code as well


No comments:

Post a Comment