Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!dali.cs.montana.edu!uakari.primate.wisc.edu!sdd.hp.com!spool.mu.edu!uunet!munnari.oz.au!goanna!ok From: ok@goanna.cs.rmit.oz.au (Richard A. O'Keefe) Newsgroups: comp.lang.c Subject: Re: Simple question. Message-ID: <5537@goanna.cs.rmit.oz.au> Date: 3 May 91 06:25:22 GMT References: <6131@gara.une.oz.au> <24528@well.sf.ca.us> Organization: Comp Sci, RMIT, Melbourne, Australia Lines: 30 In article <24528@well.sf.ca.us>, ron@well.sf.ca.us (Ronald Hayden) writes: > cfiddyme@gara.une.oz.au (Kith Kanan) writes: > > Could someone please tell me if it is possible to read a string with > > scanf() and not have the string printed on the screen. > > Thanks. > > Chris. > scanf() will always echo the characters, but getchar() won't. If > you're receiving more than one character, though, you'll have to call > getchar() multiple times, as it only processes a character at a time. This is an operating-system-specific question. On the machines I normally use, the statement "scanf() will always echo the characters, but getchar() won't" is simply false. For example, when scanf() is reading from a file, nothing is echoed. More to the point, on UNIX machines, whether echoing is done or not is part of the state of the terminal driver, and has nothing to do with which stdio functions (if any) you are using. What you _really_ want to do is to find out about the "curses" package. "curses" comes with UNIX, the "curses" interface is available in VAX/VMS C, and there are several versions of "curses" for PCs, including a free one. Using curses: noecho(); scanw(format, args...); echo(); -- Bad things happen periodically, and they're going to happen to somebody. Why not you? -- John Allen Paulos.