Date: Sun, 28 Mar 1999 14:10:17 +0200 (IST) From: Eli Zaretskii X-Sender: eliz AT is To: Jorge Pacios =?iso-8859-1?Q?Mart=EDnez?= cc: djgpp AT delorie DOT com Subject: Re: Tcl/Tk and C interaction problem In-Reply-To: <36F12924.A1AD5AA6@gmv.es> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Reply-To: djgpp AT delorie DOT com X-Mailing-List: djgpp AT delorie DOT com X-Unsubscribes-To: listserv AT delorie DOT com Precedence: bulk On Thu, 18 Mar 1999, Jorge Pacios =?iso-8859-1?Q?Mart=EDnez?= wrote: > void readcommand (char *str) { > char ch; > int i = 0; > > read(0, &ch, 1); > while (ch!='\n') { > str[i] = ch; > i++; > read(0, &ch, 1); > } > str[i] = '\0'; > } If you expect this function to read one character at a time, you need to switch stdin to raw binary mode, like this: setmode (0, O_BINARY); The problem is that DOS by default uses the so-called ``cooked mode'' when reading devices, and in that mode, `read' only returns after a newline is seen. `setmode' switches stdin into ``raw mode'' mode where you can actually read one character at a time. Note that switching stdin into raw mode also disables SIGINT generation by Ctrl-C; see the docs of the `signal' function for more details.