Path: utzoo!attcan!uunet!tut.cis.ohio-state.edu!ukma!uflorida!haven!adm!smoke!gwyn From: gwyn@smoke.BRL.MIL (Doug Gwyn) Newsgroups: comp.std.c Subject: Re: ReadKey like Function in C Message-ID: <10721@smoke.BRL.MIL> Date: 13 Aug 89 00:03:01 GMT References: <148@trigon.UUCP> <207600029@s.cs.uiuc.edu> <941@lakesys.UUCP> <21175@cup.portal.com> <3705@buengc.BU.EDU> <10712@smoke.BRL.MIL> <3727@buengc.BU.EDU> Reply-To: gwyn@brl.arpa (Doug Gwyn) Organization: Ballistic Research Lab (BRL), APG, MD. Lines: 25 In article <3727@buengc.BU.EDU> bph@buengc.bu.edu (Blair P. Houghton) writes: -In article <10712@smoke.BRL.MIL> gwyn@brl.arpa (Doug Gwyn) writes: ->The Standard must accommodate a variety of environments. -I don't get it. -All it's gotta say is something to the effect that there should -be a function, call it "readkey()", that returns the value of -the next char from stdin as soon after it's typed as it's needed. -You could even qualify it to apply only when tty input can be -used as stdin. We already have such a function in the Standard; it's called "getchar()". It returns a single character from stdin as soon as it's available. Whether or not there is input-line canonicalization going on is a matter that depends on the operating environment. Some systems always canonicalize, some never do, and some can be made to switch from one mode to the other, sometimes with side-effects like losing all unconsumed input and sometimes not. Some implementations cannot readily distinguish between "terminals" and other I/O sources/sinks. This is the "variety of environments" alluded to. Any fully portable standard for this wide a range of behavior would probably be so weak as to not meet the requirements of those who keep asking for such a facility. In fact there are are means of obtaining uncanonicalized terminal input on most systems, and as I pointed out before IEEE Std 1003.1 standardizes one such method for a wide class of systems (POSIX-compliant ones). I don't know (or much care) whether MS/DOS has any such standard, but certainly one could be developed by those who care.