Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!usc!samsung!uunet!mcsun!hp4nl!alchemy!ruunfs!boogaard From: boogaard@fys.ruu.nl (Martin vdBoogaard) Newsgroups: comp.lang.c Subject: flushing input buffer Keywords: input, flushing, portable, fgets Message-ID: <1991Apr26.152944.1928@fys.ruu.nl> Date: 26 Apr 91 15:29:44 GMT Organization: Physics Department, University of Utrecht Lines: 25 Some of my programs use gets to read lines from stdin. Suppose that (1) processing any of these lines takes a program some time and (2) the user has already entered the second line of input when the program discovers an error in the first line. When this error is detected, the program skips the rest of the offending input line (which is not likely to make much sense either). In addition I'd like to be able to skip any input the user has already entered up to the moment the program decides it must handle the error. I can't use gets because I don't know *how much* superfluous input I have to skip. The fflush function works only for *output* streams. Does anyone have a portable clue? Martin J. van den Boogaard | boogaard@fys.ruu.nl ----------------------------------------------------------------------- Dept. of Atomic & Interface Physics | the Netherlands Debye Institute--Utrecht University | phone +31 30 532904 P.O. Box 80.000, NL-3508 TA Utrecht | fax +31 30 543165 ----------------------------------------------------------------------- some days you wake up and immediately start to worry. nothing in particular is wrong, it's just the suspicion that forces are aligning quietly and there will be trouble. -- Jenny Holzer -----------------------------------------------------------------------