Only if you don't have more input than what you've told it to read.
char buf[ 5 ];
fgets( buf, 5, stdin );If you type 6 characters, you will still have input waiting.
Quzah.
Type: Posts; User: quzah
Only if you don't have more input than what you've told it to read.
char buf[ 5 ];
fgets( buf, 5, stdin );If you type 6 characters, you will still have input waiting.
Quzah.
More accurately, you should only use scanf when you know the data will be exactly formatted the way you want - that's what the f in scanf means. If you are worried about garbage input, you should use...
scanf expects you to account for every single character you enter, and it is line buffered, meaning you have to hit enter to actually have it do something with what you've been typing. That means you...