Path: utzoo!censor!geac!torsqnt!news-server.csri.toronto.edu!rutgers!cs.utexas.edu!samsung!munnari.oz.au!goanna!ok From: ok@goanna.cs.rmit.oz.au (Richard A. O'Keefe) Newsgroups: comp.lang.c Subject: Re: What's so bad about scanf anyway??? (really what's bad about gets) Message-ID: <4344@goanna.cs.rmit.oz.au> Date: 22 Nov 90 04:55:32 GMT References: <1990Nov16.165203.18786@zoo.toronto.edu> <1990Nov20.123036.11103@ericsson.se> Organization: Comp Sci, RMIT, Melbourne, Australia Lines: 33 In article <1990Nov20.123036.11103@ericsson.se>, epames@eos.ericsson.se (Michael Salmon) writes: : In article <4319@goanna.cs.rmit.oz.au> Richard A. O'Keefe writes: : >gets() will keep on reading from stdin until it hits a \n or an EOF. : >Lines entered from a keyboard _normally_ end with a \n, but they don't : >have to. Let represent your end-of-file character on a UNIX system : This is getting a long way from the original point but I thought I : should respond to this statement. It would have been better to try understanding it first. I wrote Let represent your end-of-file character on a UNIX system. People who have a UNIX system and don't know what I'm talking about should read the "stty" manual page. If they still don't understand, they should find someone who does understand and get an explanation. That or refrain from posting. The point is, of course, that the way you signal end-of-file from a keyboard in UNIX is by typing a particular character. Q: _Which_ character? A: _You_ get to pick. Some people use End-of-Transmission (^D). Some people like ^Z. I've seen ^Y used. : In C EOF is not a character, its : value is such that it can *NEVER* be present in a file. So flipping what? I said nothing whatsoever about C's EOF macro. I was talking about the key you type at the keyboard. This is totally independent of C's EOF macro and the two values have nothing in common. What I was doing was exhibiting a method of tricking gets() into reading an arbitrary number of characters from the keyboard as one "line"; that method relies on the malicious typist typing his character from time to time, whichever character he has selected for that purpose. -- I am not now and never have been a member of Mensa. -- Ariadne.