You can go into your project settings and make it a Win32 Windows application and that will hide the console window.
sfuo
Practically a Master Poster
656 posts since Jul 2009
Reputation Points: 164
Solved Threads: 99
If you are using Windows it's pretty simple, but not exactly guaranteed to not "flash" a console window for a moment.
What sfuo meant is you can tell your compiler to not spawn the console window. It's a compiler switch.
Now, this is the "dirty" way...
#include <Windows.h>
int main()
{
HWND windowHandle = GetConsoleWindow();
ShowWindow(windowHandle,SW_HIDE);
}
pseudorandom21
Practically a Posting Shark
890 posts since Jan 2011
Reputation Points: 216
Solved Threads: 111
Not really, ya just need to get a handle to the console window somehow.
http://msdn.microsoft.com/en-us/library/ms683175(v=vs.85).aspx
Okay, I think I see the problem...
Remarks
To compile an application that uses this function, define _WIN32_WINNT as 0x0500 or later. For more information, see Using the Windows Headers.
pseudorandom21
Practically a Posting Shark
890 posts since Jan 2011
Reputation Points: 216
Solved Threads: 111
right click your taskbar and select "Task Manager", go to the "Processes" tab, and kill the process.
Really, you should find the compiler option to not create the console window--it will avoid trouble like that.
pseudorandom21
Practically a Posting Shark
890 posts since Jan 2011
Reputation Points: 216
Solved Threads: 111
Okay, I used code blocks with the GCC compiler and this works for me:
#if _WIN32_WINNT < 0x0500
#undef _WIN32_WINNT
#define _WIN32_WINNT 0x0500
#endif
#include <windows.h>
int main()
{
ShowWindow(GetConsoleWindow(),SW_HIDE);
Sleep(5000);//Sleep so I can check the task manager for the process.
return 0;
}
It works inside the editor and outside of it, despite the editor making you press any key.
You can, of course, show the window again at the end of the program.
My best advice to you is to use the right compiler switch to make the console window not appear at all.
pseudorandom21
Practically a Posting Shark
890 posts since Jan 2011
Reputation Points: 216
Solved Threads: 111