here is a relevent snippets
the problem is that the first time while executes everything is ok:Code:TCHAR buf[20]; fdwMode = ENABLE_LINE_INPUT | //ReadConsole() should wait and read // characters until ENTER is pressed ENABLE_ECHO_INPUT | // show characters as you type ENABLE_PROCESSED_INPUT; // let system process all // control keystrikes SetConsoleMode(hStdin, fdwMode) ; fdwMode = ENABLE_PROCESSED_OUTPUT; SetConsoleMode(hStdout, fdwMode); while (1) { WriteConsole(hStdout, "\npress [1] for codepage: ", 25, &ch, NULL); ReadConsole(hStdin,buf,1,&ch,NULL); buf[ch]='\0'; FlushConsoleInputBuffer(hStdin); WriteConsole(hStdout, buf, 3, &ch, NULL); }
i get on screen:
i enter 1 and press enter then it prints the character.press [1] for codepage:
from this point something strange happens...
while loop continue to execute two more times despite the fact that ReadConsole() should wait for input...
anyone understand where is the problem?



LinkBack URL
About LinkBacks


