My program has to read just ONE character from the standard input, and so I use read(0, buffer, 1)
.
But if the user insert more than one single character, they remain in some buffer and when I call a read
again they are still there.
So, how can I discard these characters?
I want that when I call a read
again, the buffer is filled with the new character, not with the old ones.
An example:
I've a read(0, buffer, 1)
and the user writes abcde. My buffer contains a (and it's right), but then I call read(0, buffer, 1)
again and I want the next character written by the user from now, and not the b written before.