Path: utzoo!utgpu!attcan!uunet!munnari!murdu!strasser From: strasser@murdu.OZ (Mike Strasser) Newsgroups: comp.sys.mac.programmer Subject: Re: LSC 3.0 scanf deletes Keywords: delete, scanf Message-ID: <1421@murdu.OZ> Date: 4 Aug 88 00:10:35 GMT References: <2559@pt.cs.cmu.edu> <587@helios.ee.lbl.gov> Reply-To: strasser@murdu.UUCP (Mike Strasser) Organization: Forestry Section, University of Melbourne Lines: 26 In article <587@helios.ee.lbl.gov> beard@ux1.lbl.gov (Patrick C Beard) writes: [quote from Paul Dietz] >The answer to your question is, DON'T USE SCANF! I have always hated >the way scanf treats the user who assumes he can edit his command line. >A better approach to getting lines of input and parsing them from the user >is to use gets() and then sscanf(). For example: [etc.] The problem with doing your own buffering via gets(), strings and sscanf() is when you want a flexible interface where a user can type more than one item on a line. You then need to parse the line yourself (when scanf() on an input stream will do that adequately) or find a way of knowing how much of the string has been parsed by sscanf(), so second and subsequent calls will not start at the beginning of the string again. --------------------------------------------------------------------------- Mike Strasser ACSnet, CSnet: strasser@murdu.oz Internet: strasser%murdu.oz@uunet.uu.net Forestry Section University of Melbourne Creswick, Victoria. 3363 Phone: (053) 45 2405 A u s t r a l i a +61 53 45 2405 ---------------------------------------------------------------------------