U++ framework
Do not panic. Ask here before giving up.

Home » Extra libraries, Code snippets, applications etc. » C++ language problems and code snippets » capturing stdout/err/in of subprocess
Re: capturing stdout/err/in of subprocess [message #1716 is a reply to message #1705] Wed, 15 March 2006 00:09 Go to previous messageGo to previous message
gprentice is currently offline  gprentice
Messages: 260
Registered: November 2005
Location: New Zealand
Experienced Member




Quote:

void main() { getchar(); }

Start that. The program will stop, allowing you to enter the line of input characters. Now this "enter the line of characters" is that "echoing" I am speaking about. And, AFAIK, this is not done by program, but terminal (in any case, it is terminal responsibility that if you press backspace, last character is removed from the input line).



Wow, I never noticed that. (I don't write console programs much.)

I tried the following program (with Borland compiler on Win XP). If I run it, the first key that gets pressed doesn't get echoed but its numeric value does get printed, then I can press a bunch of keys that do get echoed (and backspace works just as you say) and when I finally press return, the program exits.

getch() is Borland extension (and kbhit) - I think VC has similar ones. I wonder why the first keypress doesn't get echoed. If I change getch() to getchar(), the first character and following characters (until I press return) do get echoed, after which the numeric value gets printed. Maybe getchar() hooks up to a blocking OS function that runs in "line buffer" mode and getch() doesn't run in line mode.

Graeme



#include <stdio.h>
#include <conio.h>

int main()
{
    while (1)
    {
        if (kbhit())
        {
            printf(" yes");
            int k = getch();
            printf( "%d", k);
            break;
        }
    }
    getchar();
}

 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: New EH handling in MinGW
Next Topic: DLL and U++ type
Goto Forum:
  


Current Time: Sun May 24 08:59:44 GMT+2 2026

Total time taken to generate the page: 0.00578 seconds