Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!sdd.hp.com!uakari.primate.wisc.edu!aplcen!uunet!mcsun!unido!sbsvax!fs-info From: fs-info@sbsvax.cs.uni-sb.de (c/o Peter Gaal) Newsgroups: comp.os.msdos.programmer Subject: reading stdin one character at the time Keywords: stdin nonblocking ioctl Message-ID: <6054@sbsvax.cs.uni-sb.de> Date: 17 Aug 90 09:39:55 GMT Organization: Universitaet des Saarlandes, Saarbruecken, W-Germany Lines: 33 HiHo! I hope someone may help me with the following problem: Asume this C fragment: int dev_ready(int handle) /* does an ioctl() call on handle to get an input-ready status * This should work, assume it does. */ { some code... } ... setraw(fileno(stdin)); while (!dev_ready(fileno(stdin)) { /* do something 'til a key is hit */ } c=fgetc(stdin); /* read ONE character */ The task is: query if a character is present on some handle, if not, do something else, and if it is, read exactly this character. The Problem is the function setraw() above, which should set a CON: device (normally associated with stdin) into a raw mode. All experiments 'til now failed to force the CON: device to read the keyboard one character at the time - it allways reads a complete line which breaks the nonblocking intention of the above. Important: I do not want code reading the keyboard directly (via BIOS or so), I need the possibility to continue working with the handle only. Please E-Mail suggestions, and only post code if it's tested... Thanx in advance Patrick