I have a Windows based application. I made it to work in for both GUI Mode and Console Mode. In GUI mode or Console mode I am attaching a Console by using AttachConsole() to bring up output print statements to the console. Now the challenge is, I don't need new console to come up while I am using it in console mode or from Command prompt.
Suppose from command prompt, I am running it as
d:\Project path > MyApp.exe consolemode **Enter**
Then it brings up the another console, because of Attachconsole(). Now when I disable the AttachConsole() it does not bring up the new console and it does not show the output in command prompt too. But my requirement is to show the output in commandprompt instead of bringing up new console while executing from comamnd prompt.
Myapp.cpp
Winmain()
{
....
...
AttachConsole();
cout << "Console Attached \n";
// Some more output
}
So, when i run the myapp.exe from command promt
d:\Project path > MyApp.exe consolemode **Enter**
it attaches a new console and prints the output in new console window. Now my requirement is I need to disable AttachConsole(); and wanted to see the output in the command prompt.
Myapp.cpp
Winmain()
{
....
...
//AttachConsole(); //Now I an disabling console
cout << "Console Attached \n";
// Some more output
}
If you look at the code above I have disabled the AttachConsole(). Now want when I do,
d:\Project path > MyApp.exe consolemode **Enter**
The output will come in comamnd prompt. like below
d:\Project path > MyApp.exe consolemode **Enter**
Console Attached
....
...
d:\Project path >
Please help me
Attachit, you mess default output. So you will need to also comment out that line in such case.