+ 8

Flush stdin

How can I flush stdin in c without use fflush function

26th Dec 2018, 2:48 PM
ABADA S
ABADA S - avatar
1 Respuesta
+ 2
You can just read / get on stdin until you hit whatever character indicates "stop flushing" Basically, ignore/discard input up to a certain point, like a space, or \n or EOF. note to visitors: fflush(any input stream) is undefined behavior; nothing about this question should imply that's an alternative. ref: Why fflush(stdin) is wrong https://faq.cprogramming.com/cgi-bin/smartfaq.cgi?answer=1052863818&id=1043284351
26th Dec 2018, 5:13 PM
Kirk Schafer
Kirk Schafer - avatar