Path: utzoo!attcan!uunet!convex!killer!vector!rpp386!jfh
From: jfh@rpp386.UUCP (The Beach Bum)
Newsgroups: comp.lang.c
Subject: Re: Echoing chars and input functions
Message-ID: <5582@rpp386.UUCP>
Date: 18 Aug 88 23:05:03 GMT
References: <8808160751.aa03016@SMOKE.BRL.MIL> <8349@smoke.ARPA> <2821@boulder.Colorado.EDU>
Reply-To: jfh@rpp386.UUCP (The Beach Bum)
Organization: HASA, "S" Division
Lines: 30

In article <2821@boulder.Colorado.EDU> swarbric@tramp.Colorado.EDU (Frank Swarbrick) writes:
>In article <8349@smoke.ARPA> gwyn@brl.arpa (Doug Gwyn (VLD/VMB) ) writes:
>>In article <8808160751.aa03016@SMOKE.BRL.MIL> dsill@NSWC-OAS.ARPA (Dave Sill) writes:
>>>What, then, is the portable way to input a character from standard input,
>>>echoing the character to the screen when necessary?
>>
>>We already answered that!  It's
>>	c = getchar();
>
>I could have sworn someone said their compiler did not echo the character when
>they used this.  Did I misunderstand someone, or is their compiler just
>non-conformant (broken)?

perhaps what needs to be said is that getchar() does not echo characters.
the operating system does.  if ms-dos does not perform character echoing
when reading from the keyboard, then this becomes an operating system
issue, not a language one.  likewise for all operating systems which C
is used on.  the description for getchar() is "read a character from
standard input".

a portable way to do "echoing" would be

	(c = getchar ()) != EOF && putchar (c);

this explicitly echoes the characters.  it is also "broken" on unix.
-- 
John F. Haugh II                 +--------- Cute Chocolate Quote ---------
HASA, "S" Division               | "USENET should not be confused with
UUCP:   killer!rpp386!jfh        |  something that matters, like CHOCOLATE"
DOMAIN: jfh@rpp386.uucp          |         -- apologizes to Dennis O'Connor