Thread: problem with console app

  1. #1
    Registered User
    Join Date
    Mar 2004
    Posts
    36

    problem with console app

    here is a relevent snippets

    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); 
    }
    the problem is that the first time while executes everything is ok:
    i get on screen:
    press [1] for codepage:
    i enter 1 and press enter then it prints the character.

    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?
    Last edited by Jumper; 07-04-2004 at 06:19 AM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. CreateRemoteThread in suspended app problem
    By doy2001 in forum Windows Programming
    Replies: 5
    Last Post: 08-15-2008, 07:31 AM
  2. Replies: 12
    Last Post: 05-06-2006, 03:34 PM
  3. Console App Question
    By Sentral in forum C++ Programming
    Replies: 11
    Last Post: 07-21-2005, 12:37 PM
  4. Graph in console app.
    By MipZhaP in forum C++ Programming
    Replies: 4
    Last Post: 02-26-2005, 07:02 AM
  5. Project Builder console app
    By Luigi in forum C++ Programming
    Replies: 0
    Last Post: 12-28-2002, 07:57 PM