Skip to content

Instantly share code, notes, and snippets.

@mojocorp
Last active March 1, 2018 22:30
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mojocorp/d1a0b400abd790f44a53 to your computer and use it in GitHub Desktop.
Save mojocorp/d1a0b400abd790f44a53 to your computer and use it in GitHub Desktop.
Windows winmain argc argv console application
#ifdef _WIN32
#include <windows.h>
#include <stdio.h>
#pragma warning(disable: 4996)
extern int main(int argc, char* argv[]);
int WINAPI WinMain(HINSTANCE /*hInstance*/,
HINSTANCE /*hPrevInstance*/,
LPSTR /*lpCmdLine*/,
int /*nCmdShow*/)
{
// Redirect stdin, stdout, stderr to the console.
if (AttachConsole(ATTACH_PARENT_PROCESS)) {
freopen("CONIN$", "r", stdin);
freopen("CONOUT$", "w", stdout);
freopen("CONOUT$", "w", stderr);
}
return main(__argc, __argv);
}
#endif //_WIN32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment