bchurch@oucsace.cs.OHIOU.EDU (Bob Church) (06/04/90)
I am trying to read a key from the keyboard in C. I want to be able to read a single key such as a cursor without pressing return. I put together a short function which directly accesses STROBE and KBD. This works but is obviously machine dependent. Is there a "true C" way of doing this? All of the C functions seem to depend upon return being pressed. ******************************************************************** * * * bob church bchurch@oucsace.cs.ohiou.edu * * * * If economics isn't an "exact" science why do computers crash * * so much more often than the stock market? * * bc * ********************************************************************
unknown@ucscb.UCSC.EDU (The Unknown User) (06/07/90)
In article <1422@oucsace.cs.OHIOU.EDU> bchurch@oucsace.cs.OHIOU.EDU (Bob Church) writes: >works but is obviously machine dependent. Is there a "true C" way of >doing this? All of the C functions seem to depend upon return being >pressed. Maybe I'm missing something, but are you talking about: scanf("%c",&charvariablename); That's a "true C" way of doing it. -- _ __ __ __ _ /-------------------------------\ /_\ |__| | __|(GS) |_| |_ \ / |_| | unknown@ucscb.ucsc.edu | / \ | |__ |__ | |__ \/ | \ | unknown%darkside.com@ames.arpa | Computer engineering student seeking a job. \-------------------------------/
gwyn@smoke.BRL.MIL (Doug Gwyn) (06/08/90)
In article <1422@oucsace.cs.OHIOU.EDU> bchurch@oucsace.cs.OHIOU.EDU (Bob Church) writes: >I am trying to read a key from the keyboard in C. I want to be able >to read a single key such as a cursor without pressing return. I put >together a short function which directly accesses STROBE and KBD. This >works but is obviously machine dependent. Is there a "true C" way of >doing this? All of the C functions seem to depend upon return being >pressed. There is no portable facility for this in C. Some systems do not even provide ANY way to accomplish a keyin() function. Those that do, use different methods to accomplish it. Your best bet is to design an interface that can be implemented in most environments and have your application use that interface; the implementation of the interface will have to be done for each different system time to which you port your applications. For example, extern void rawmode(); /* enter single-key input mode */ extern void cookedmode(); /* resume line-at-a-time mode */ extern int getkey(); /* return next available character */
herwin@pro-novapple.cts.com (Harry Erwin) (06/09/90)
In-Reply-To: message from bchurch@oucsace.cs.OHIOU.EDU
>I am trying to read a key from the keyboard in C.
There is no "true" C way of doing this. Under UNIX, the approach is to use
curses, but no one has constructed a curses library for the GS--I tried and it
has been incredibly painful. For the GS, you need to use the GSOS calls.
Harry Erwin
proline: pro-novapple!herwin
gnh-starport!herwin
uucp: crash!pro-novapple!herwin
crash!pnet01!gnh-starport!herwin
arpa: crash!pro-novapple!herwin@nosc.mil
crash!pnet01!gnh-starport!herwin@nosc.mil
Internet: herwin@pro-novapple.cts.com
Telenet: herwin/trw
Applelink: herwin
bchurch@oucsace.cs.OHIOU.EDU (Bob Church) (06/12/90)
In article <4145@darkstar.ucsc.edu>, unknown@ucscb.UCSC.EDU (The Unknown User) writes: > > In article <1422@oucsace.cs.OHIOU.EDU> bchurch@oucsace.cs.OHIOU.EDU (Bob Church) writes: > >works but is obviously machine dependent. Is there a "true C" way of > >doing this? All of the C functions seem to depend upon return being > >pressed. > > Maybe I'm missing something, but are you talking about: > > scanf("%c",&charvariablename); > > That's a "true C" way of doing it. > > -- Have you actually tried this? On my system SCANF waits until return is pressed. What software are you using? ******************************************************************** * * * bob church bchurch@oucsace.cs.ohiou.edu * * * * If economics isn't an "exact" science why do computers crash * * so much more often than the stock market? * * bc * ********************************************************************
unknown@ucscb.UCSC.EDU (The Unknown User) (06/15/90)
In article <1440@oucsace.cs.OHIOU.EDU> bchurch@oucsace.cs.OHIOU.EDU (Bob Church) writes: >Have you actually tried this? On my system SCANF waits until return is >pressed. What software are you using? Well, I'm just talking about the definition of C.. and how UNIX C works... -- _ __ __ __ _ /-------------------------------\ /_\ |__| | __|(GS) |_| |_ \ / |_| | unknown@ucscb.ucsc.edu | / \ | |__ |__ | |__ \/ | \ | unknown%darkside.com@ames.arpa | Computer engineering student seeking a job. \-------------------------------/
gwyn@smoke.BRL.MIL (Doug Gwyn) (06/16/90)
In article <4412@darkstar.ucsc.edu> unknown@ucscb.UCSC.EDU (The Unknown User) writes: >Well, I'm just talking about the definition of C.. and how UNIX C works... The definition of C != how UNIX C works != what you are talking about