problem with console app

This is a discussion on problem with console app within the Windows Programming forums, part of the Platform Specific Boards category; here is a relevent snippets Code: TCHAR buf[20]; fdwMode = ENABLE_LINE_INPUT | //ReadConsole() should wait and read // characters until ...

  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?
    Attached Files Attached Files
    Last edited by Jumper; 07-04-2004 at 07: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, 08:31 AM
  2. Replies: 12
    Last Post: 05-06-2006, 04:34 PM
  3. Console App Question
    By Sentral in forum C++ Programming
    Replies: 11
    Last Post: 07-21-2005, 01: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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21