No output to stdout :-( - Programmer

This is a discussion on No output to stdout :-( - Programmer ; I have an MFC app with a simple dialog but I want to now not instantiate the dialog but still let the remainder of the exe run to completion and print the results to standard out ( just as a ...

+ Reply to Thread
Results 1 to 2 of 2

Thread: No output to stdout :-(

  1. No output to stdout :-(

    I have an MFC app with a simple dialog but I want to now not
    instantiate the dialog but still let the remainder of the exe run to
    completion and print the results to standard out ( just as a Win32
    console app does ) in the good old Hello World example using cout.

    However, when I put any couts in the app and run it from a command
    prompt I get no output at all :-(

    Also tried ( in desperation ) printf and fprintf(stdout....) but got
    nowt.

    Is stdout redirected away from the commanding window.

    Any ideas anybody.

    OK, it's still dialog based but I want some output back at the command
    prompt.

    Thanks in advance

    Paul.

  2. Re: No output to stdout :-(

    HoHum schrieb:

    > I have an MFC app with a simple dialog but I want to now not


    HANDLE con;
    COORD coord;

    //stdout
    AllocConsole();
    SetConsoleTitle("stdout");
    con= CreateFile("CON",GENERIC_WRITE,FILE_SHARE_READ |
    FILE_SHARE_WRITE
    ,NULL,0,0,0);
    coord.X = 10;
    coord.Y = 100;
    freopen("CON", "wt", stdout);
    SetConsoleTextAttribute(con, FOREGROUND_GREEN);
    SetConsoleScreenBufferSize(
    GetStdHandle(STD_OUTPUT_HANDLE), coord );

+ Reply to Thread