When you create an application for the CONSOLE subsystem (using the /SUBSYSTEM:CONSOLE linker switch), the system allocates a console automatically.
If you don't want the system to allocate a console for your process, specify the /SUBSYSTEM:WINDOWS linker switch. This also requires a different application entry point signature:
int APIENTRY wWinMain( HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPWSTR lpCmdLine,
int nCmdShow ) {
const wchar_t* title = L"Message box title";
const wchar_t* message = L"I am working";
MessageBoxW( NULL, message, title, MB_OK | MB_ICONEXCLAMATION );
return 0;
}
When using Visual Studio, you can change the subsytem through the project settings GUI:

Note, that I changed the character encoding to use Unicode. This is the default encoding Windows uses internally. To make the compiler pick up the wWinMain
entry point, you need to set the character encoding in the project settings accordingly (General -> Character Set: Use Unicode Character Set).