Path: utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!apple!sun-barr!texsun!texbell!uhnix1!sugar!ficc!peter From: peter@ficc.uu.net (Peter da Silva) Newsgroups: comp.lang.c Subject: Re: Re^2: scanf(..) Message-ID: <4529@ficc.uu.net> Date: 13 Jun 89 13:13:19 GMT References: <225800176@uxe.cso.uiuc.edu> <11831@bloom-beacon.MIT.EDU> <4734@freja.diku.dk> Organization: Xenix Support Lines: 26 scs@adam.pika.mit.edu (Steve Summit) writes: >It is only a miserable problem when scanf >is being used for interactive user input, which is what everybody >uses it for. Anyone using scanf directly for interactive input... or for any input at all... should have their head examined. The only really safe way to use scanf() without freaking out the casual user of your code is to do something like this: fgets(buffer, sizeof buffer, stdin); sscanf(buffer, fmt, args...); Sure, you can probably cons up a format string that does what you want, but who needs the aggravation? [ By the way, it really bugs me that stdio is so inconsistant about the position of the inevitable 'stream' argument? In an ideal world that code would read "fgets(stdin, buffer, sizeof buffer)", no? ] -- Peter da Silva, Xenix Support, Ferranti International Controls Corporation. Business: uunet.uu.net!ficc!peter, peter@ficc.uu.net, +1 713 274 5180. Personal: ...!texbell!sugar!peter, peter@sugar.hackercorp.com.