Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!uunet!husc6!cmcl2!brl-adm!adm!TGMIKEY%CALSTATE.BITNET@wiscvm.wisc.EDU From: TGMIKEY%CALSTATE.BITNET@wiscvm.wisc.EDU (Account Manager) Newsgroups: comp.lang.c Subject: RE: Re: HELP!! Message-ID: <10318@brl-adm.ARPA> Date: Fri, 13-Nov-87 13:27:41 EST Article-I.D.: brl-adm.10318 Posted: Fri Nov 13 13:27:41 1987 Date-Received: Sun, 15-Nov-87 09:32:08 EST Sender: news@brl-adm.ARPA Lines: 74 Received: by CALSTATE via BITNet with NJF for TGMIKEY@CALSTATE; Comment: 10 Nov 87 03:10:42 PST Received: by BYUADMIN (Mailer X1.24) id 2476; Tue, 10 Nov 87 04:09:47 MST Date: 6 Nov 87 05:32:07 GMT Reply-To: Info-C@BRL.ARPA Sender: INFO-C@NDSUVM1 From: platt@emory.uucp Subject: Re: HELP!! Comments: To: info-c@brl-smoke.arpa To: TGMIKEY@CCS.CSUSCC.CALSTATE.EDU In article jl3j+@andrew.cmu.edu (John Robert Leavitt) writes: >Okay people, > > The situation is this. We need a way of getting one character from >stdin without having to hit return. That's it. > >Please, if you think you know how, drop me a line, okay? Thanks. > > -John. > Here is a hint at least: #include #include getttyc() { struct sgttyb status_in,status_out; int chr; ioctl(0,TIOCGETP,&status_in); status_out=status_in; status_in.sg_flags = CBREAK; status_in.sg_flags &= ~ECHO; ioctl(0,TIOCSETP,&status_in); chr=getchar(); ioctl(0,TIOCSETP,&status_out); return(chr); } char *getttys(a) char *a; { while((*a++ = getttyc())!='\n'); *a='\0'; return(a); } Hope this is a help! Dan ===== Reply from Mike Khosraviani ========================== C provides you two functions for that : (1) x = getch(); where x is char x; This will return a character from the keyboard (without echoing that character) and it does NOT require the user to follow his/her input with a . (2) x = getche(); where x is as above and the difference between this one and the above getch() is that the character will get echoed to the user as soon as typed. Please, check your manual for more information on the kind of compiler that you are using. Also, I hope that I have understood the question correctly and my answer will be of some help. Mike