Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

stdin waits for no gets or fgets

Status
Not open for further replies.

PowerNuke

Programmer
Joined
Oct 7, 2001
Messages
10
Location
US
I am trying to use:
gets( userInput ); or
fgets( userInput, 21, stdin );

to get a string from the keyboard. Instead of stopping, it blows by the statement leaving a NULL string in its wake! The only thing I can think is that I used scanf earlier in the program. Any troubleshooting suggestions will be appreciated.

Thanks,

David
 
use fflush(stdin) before the fgets().

Brudnakm
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top