Results 1 to 2 of 2

Thread: console with MFC

  1. #1

    Thread Starter
    New Member
    Join Date
    Apr 2009
    Posts
    10

    Question console with MFC

    HEY EVERBODY

    I want to use printf() in MFC , i have used but its not give any output, i also used allocconsole but its working well.

  2. #2

    Thread Starter
    New Member
    Join Date
    Apr 2009
    Posts
    10

    Question Re: console with MFC

    I also used following code but its give error that of std is ilegal .
    AllocConsole( );

    // setup stdout
    {
    int fd = _open_osfhandle( (long)GetStdHandle( STD_OUTPUT_HANDLE ), 0);
    FILE* fp = _fdopen( fd, "w" );

    *stdout = *fp;
    setvbuf( stdout, NULL, _IONBF, 0 );
    }
    // setup stdin
    {
    int fd = _open_osfhandle( (long)GetStdHandle( STD_INPUT_HANDLE ), 0);
    FILE* fp = _fdopen( fd, "r" );

    *stdin = *fp;
    setvbuf( stdin, NULL, _IONBF, 0 );
    }

    // test stdin & stdout
    std::cout << "Console in place. Type a number: ";
    /*
    int x = 0;
    std::cin >> x;

    std::cout << "Value read: " << x << std::endl;

    // generated code
    */

    FreeConsole();

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width