after i do scanf i want to check if the buffer is clean
how to know that the buffer is not clean??
after i do scanf i want to check if the buffer is clean
how to know that the buffer is not clean??
Give it a sniff!
Seriously, tho, you will be much happier with life if you write 'lil fgetc() or read() functions like me
C programming resources:
GNU C Function and Macro Index -- glibc reference manual
The C Book -- nice online learner guide
Current ISO draft standard
CCAN -- new CPAN like open source library repository
3 (different) GNU debugger tutorials: #1 -- #2 -- #3
cpwiki -- our wiki on sourceforge
dosent scanf by definition take all chars from input buffer and transfer to the buffer inside your program?
hangon which buffer??? the terminal or your C buffer???
No. It doesn't transfer anything, it converts the input characters according to the conversion specifiers. Characters which are converted are removed from the buffer. If a conversion fails, the characters which did not convert REMAIN in the buffer.
And we are talking about the stdio buffer, not the terminal buffer.
Code://try //{ if (a) do { f( b); } while(1); else do { f(!b); } while(1); //}
use fgets/sscanf pair
All problems in computer science can be solved by another level of indirection,
except for the problem of too many layers of indirection.
– David J. Wheeler