Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!uunet!mcsun!ukc!edcastle!aipna!rjc From: rjc@uk.ac.ed.cstr (Richard Caley) Newsgroups: comp.lang.c Subject: Re: What's so bad about scanf anyway??? Message-ID: Date: 13 Nov 90 12:28:22 GMT References: <16582@netcom.UUCP> <1990Nov12.112032.22979@diku.dk> Sender: news@aipna.ed.ac.uk Organization: Center for Speech Technology Research Lines: 29 In-reply-to: kimcm@diku.dk's message of 12 Nov 90 11:20:32 GMT In article <1990Nov12.112032.22979@diku.dk> kimcm@diku.dk (Kim Christian Madsen) writes: 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! Sorry for being confusing, I wasn't defending scanf, I was just pointing out the fact that gets is never useful. -- rjc@uk.ac.ed.cstr _O_ |<