Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!swrinde!mips!apple!olivea!mintaka!bloom-beacon!eru!hagbard!sunic!dkuug!freja.diku.dk!kimcm From: kimcm@diku.dk (Kim Christian Madsen) Newsgroups: comp.lang.c Subject: Re: What's so bad about scanf anyway??? Message-ID: <1990Nov12.112032.22979@diku.dk> Date: 12 Nov 90 11:20:32 GMT References: <16582@netcom.UUCP> Organization: Department Of Computer Science, University Of Copenhagen Lines: 22 rjc@uk.ac.ed.cstr (Richard Caley) writes: >In article roy%cybrspc@cs.umn.edu (Roy M. Silvernail) writes: > The problem with scanf() is that it can behave unpredictably when you > give it badly formatted input. It's better, IMHO, to gets() a whole > line, check its validity and _then_ sscanf() it into the target > variables. >Maybe it was just a typo, but repeat after me > `GETS is EVIL' >This has been un unpayed anouncement by paranoids anonymous. gets can get you into a lot of trouble if used for in a non-controlled manner, e.g. for user input. Then you be better off by using fgets or reading char-by-char with getchar() or family. But using scanf() for user input is asking for trouble! Kim Chr. Madsen just as