|
From: Phillip S. <ps...@cf...> - 2002-04-30 23:53:45
|
Consoles by default are line buffered, so they only return an entire line when \n is hit. If you want to, you can change the console mode to not be line buffered with SetConsoleMode(), but I don't think that CRTs usually do this: they just leave it as line buffered. At 12:30 AM 5/1/2002 +0200, you wrote: >Hey all > >I'm trying to track down a bug in gets (in msvcrt). Here's the problem, >based on the calls made: > >1: gets calls getchar to get each character, checking for \n or EOF >2: getchar calls getc, using STDIN as the file handle >3: getc calls _filbuf, again passing the file handle (STDIN) >4: _filbuf calls _read >5: _read calls ReadFile >6: ReadFile calls ReadConsoleA because IsConsoleHandle returns true > >ReadConsoleA gets a series of characters from the keyboard and only >returns when it gets a \n. So in effect, getchar is getting an entire >string from the console instead of a single character. > >At which point is the fault? Should ReadFile call ReadConsoleA? Or perhaps >is the fault in calling _filbuf? I don't know... I really need some advice >on this. > >Thanks!! > >- Jason |