Since this program uses the Windows API, you need to include Windows.h with the appropriate definition of _WIN32_WINNT.
I'm very rusty with the Windows API, but (if I remember correctly) you can do something like this:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
// required for use of newer APIs (e.g., GetConsoleWindow())
# define _WIN32_WINNT 0x0500
// required for use of the Win32 API
# include <Windows.h>
int main() {
HWND console_handle = GetConsoleWindow();
if (! console_handle) { /* no console associated with the calling process */
return 1;
}
ShowWindow(console_handle, SW_HIDE);
// The console should be hidden - your code follows.
}