Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!uunet!husc6!rutgers!ukma!gatech!emory!platt From: platt@emory.uucp (Dan Platt) Newsgroups: comp.lang.c Subject: Re: HELP!! Message-ID: <2304@emory.uucp> Date: Fri, 6-Nov-87 00:32:07 EST Article-I.D.: emory.2304 Posted: Fri Nov 6 00:32:07 1987 Date-Received: Sun, 8-Nov-87 14:46:58 EST References: Reply-To: platt@emory.UUCP (Dan Platt) Organization: Math and Computer Science, Emory University, Atlanta GA Lines: 42 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