Jim Showalter <> writes:
> 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?
I see you've already fixed the problem, but for future reference we
can help you much better if you'll post actual code. If you don't
understand the code yourself, it's highly unlikely that you'll be able
to describe it accurately enough for us to diagnose it.
--
Keith Thompson (The_Other_Keith)
kst- <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.