|
-
Apr 23rd, 2009, 08:33 AM
#1
Thread Starter
New Member
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.
-
Apr 23rd, 2009, 08:36 AM
#2
Thread Starter
New Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|