I have a Visual C++ console application (I am using windows Vista, Visual studio 2008). When executing the program i don't want to see the Console popping up. How do i code this.

I tried simply removing all cout and printf statements but yet this didn't help.

Need help here.

Dani AI

Generated

Short answer: the console window is created by the linker because your project is a "Console" subsystem program — removing cout or printf won’t stop Windows from creating the console. asked why the console still appears; and pointed out two common routes (make a Win32/Windows app or hide the console at runtime). Both work, but there are cleaner, more robust options.

Clean fix in Visual Studio 2008 (no code changes required): change the project subsystem to Windows so the OS won’t create a console at process start. In Project Properties go to Configuration Properties → Linker → System → SubSystem and choose “Windows (/SUBSYSTEM:WINDOWS)”. If you still want to keep a main() function rather than converting to WinMain, set Configuration Properties → Linker → Advanced → Entry Point to mainCRTStartup. Rebuild both Debug and Release configs after changing these settings.

Trade-offs and practical tips: runtime-hiding the console (what showed) can work but may produce a brief flash and still leaves CRT console behavior intact. If your program needs occasional console-style diagnostics during development, use debug-only techniques (attach a console in debug builds, write to a log file, or use the debug output) rather than shipping a visible console. If the app is a long-running background task, consider a Windows Service or launching the child process with the detached/hidden flag so no console is created at all.

Quick troubleshooting checklist: rebuild after changing subsystem; if you get an unresolved entry-point error, confirm the Entry Point setting; remember standard I/O will no longer appear — redirect or log if needed; and keep separate Debug configuration settings so you can still see console output while developing.

Recommended Answers

All 3 Replies

this might help you out

Or much more simple you could create a main win32 project and not define or register a window class:

int __stdcall WInMain (HINSTANCE hInstance,HINSTANCE hPrevInstance,LPSTR szCmdArg,INT nCmdShow)  {
//code here
   MessageBox (NULL,"Output",NULL,MB_OK); //output stuff
 }

or just hide the window

#include <windows.h>
int main()
{
   HWND hWnd = GetConsoleWindow();
   ShowWindow(hWnd,SW_HIDE);
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.