ReadKey like Function in C

Doug Gwyn gwyn at smoke.BRL.MIL
Fri Aug 18 01:51:15 AEST 1989


In article <21372 at cup.portal.com> Kevin_P_McCarty at cup.portal.com writes:
>Agreed, except that such an environment, with its canonicalized input,
>does not encompass every application.  Such an environment is not the
>only one for which C programs are written.

And neither is a direct keyboard reading one.  Therefore it would be
inappropriate for a universal standard to attempt to legislate either
behavior.

>Programming with kbhit() and getch() is programming for an embedded
>system, ...

While getchar() etc. are required only in a hosted environment.  A
hosted environment is supposed to provide a fairly cozy set of
capabilities.  Although input canonicalization is not specifically
required, it is the sort of thing that might be reasonably expected
in a hosted environment.

>It is mostly programmers writing applications suited for these
>rudimentary platforms who need kbhit() and getch().  They only need them
>for embedded system types of programs, not for any applications which
>have a hope of porting elsewhere.

That is what the C Standard calls a "freestanding" environment.  Since
freestanding environments vary much more widely than hosted ones, the
Standard attempts to constrain them as little as possible.  For those
that have keyboards, perhaps kbhit() and getch() would be useful things
for the implementation to provide.  It's not clear that a flight control
system should be burdened with them.

>I see no need to go beyond the current state of affairs.
>Just because they are useful for some kinds of programming is
>no reason to canonize them into the language for everybody.

Right on!



More information about the Comp.lang.c mailing list