[Courses] [C] whats wrong with scanf?

Morgon Kanter admin at surgo.net
Sun Nov 10 15:16:44 EST 2002


Ahh, I see now. Thank you!

Morgon

> If you use scanf(), then all leading whitespace including newlines will be
> ignored. So, a user who gets a prompt has to enter *something* before they
> can get past it - hitting enter will do nothing.
>
> The other reason is that scanf() only ever gives you one chance to look at
> the data. If it doesn't match the input expression, you've lost it
> forever. Worse, there may be input waiting but unprocessed, which will
> confuse the next scanf() you do. There's no easy portable way to tell
> whether input is waiting.

-- 
Fetch my public key from http://www.surgo.net/pubkey.asc



More information about the Courses mailing list