J
Jim Showalter
I use getchar() to get the user's menu choice. One of the
choices is to enter strings of information, for which I use
fgets(str, 21, stdin). But when it's called, fgets() gets
a null string. The previous use of getchar() evidently
doesn't clear stdin. I've tried using fflush(stdin) before
the call to fgets(), but it makes no difference.
How do I prevent this undesirable behavior?
choices is to enter strings of information, for which I use
fgets(str, 21, stdin). But when it's called, fgets() gets
a null string. The previous use of getchar() evidently
doesn't clear stdin. I've tried using fflush(stdin) before
the call to fgets(), but it makes no difference.
How do I prevent this undesirable behavior?