Reputation: 29377
this code is compiled with -mwindows
under gcc , there is no winapi error message.
#include <windows.h>
#include <stdio.h>
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE, LPTSTR, int nCmdShow) {
AllocConsole();
printf("%s\n", "sample text");
return 0;
}
Result is that console is black empty, no text, no error message.
Upvotes: 0
Views: 179
Reputation: 129314
Use:
freopen("CONOUT$", "wb", stdout);
to reopen the stdout
after you have created the console. If you plan on using it for input too, then you need:
freopen("CONIN$", "rb", stdin);
and stderr may need opening too:
freopen("CONOUT$", "wb", stderr);
Upvotes: 1