Date: Sun, 08 Oct 2000 12:31:56 +0200 From: "Eli Zaretskii" Sender: halo1 AT zahav DOT net DOT il To: dgrant79 AT hotmail DOT com Message-Id: <5567-Sun08Oct2000123156+0300-eliz@is.elta.co.il> X-Mailer: Emacs 20.6 (via feedmail 8.3.emacs20_6 I) and Blat ver 1.8.5h CC: djgpp AT delorie DOT com In-reply-to: <39e03e07_4@news1.prserv.net> (dgrant79@hotmail.com) Subject: Re: Getting characters from keyboard without CR References: <39e03e07_4 AT news1 DOT prserv DOT net> Reply-To: djgpp AT delorie DOT com Errors-To: nobody AT delorie DOT com X-Mailing-List: djgpp AT delorie DOT com X-Unsubscribes-To: listserv AT delorie DOT com Precedence: bulk > From: "David Grant" > Newsgroups: comp.os.msdos.djgpp > Date: Sun, 8 Oct 2000 02:20:01 -0700 > > Can anyone tell me how to get a character from the screen (I mean keyboard) > without requiring a carriage return? cin won't work, and neither will > "&istream get(char c)" funtion. The problem is that by default, stdin is in line-buffered mode. Unfortunately, there's no ANSI standard way of getting a non-default behavior that you want. If you want your code to be portable to Unix environments, use the termios functions to switch the standard input into a single-character mode. The docs of the DJGPP library describes the termios capabilities, see the node "Termios functions" in libc.info. The DJGPP archives, http://www.delorie.com/djgpp/mail-archives/, have some messages relevant to this issue (search for "termios") which can help you with details. Note that termios might not be portable to other DOS/Windows compilers, with the notable exception of Cygwin. But it is portable to Unix and GNU/Linux systems. Alternatively, you could switch stdin into raw mode with a call to the library function setmode. This is probably DJGPP-specific (although setmode exists in other compilers). The library docs of setmode should explain its effect and give some examples.