Mail Archives: djgpp/1996/05/30/06:13:52
On 29 May 1996, Dominique Micollet wrote:
> The %[^\n] allows to catch any character excepted the new line and then to
> get strings with blanks, tabs and so on inside them.
> The fflush(stdin) is there to trash the new line, else the next scanf of a
> string does not works.
> This works fine with many compilers (RS6000, SUN, DEC, PC)
ANSI C Standard says (para 7.9.5.2) that `fflush' is only defined for
output streams; otherwise what `fflush' does is undefined. You shouldn't
use `fflush' at all for an input stream. To skip the newline, use `fgets'
(or just `getc' if you know there is only a single newline).
- Raw text -