I am programming a game in C++. I want to print debugging messages from within my code using std::cout, but as this is a GUI application there is no console to print to by default. I have tried simply running it from CMD like this:
start Debug/hydro.exe
But to no avail.
On Windows 8 x86_64 using Visual Studio 2012 with a Win32 project, the following code achieves what I am looking for:
#include <Windows.h>
...
AllocConsole();
freopen("CONIN$", "r",stdin);
freopen("CONOUT$", "w",stdout);
freopen("CONOUT$", "w",stderr);
However, I believe that this not cross-platform (do correct me if I am wrong!) and would like my application to work on Linux and Mac OS X.
Is there a cross-platform solution to this? Of course, the simpler the better!
std::cout? That's how most programs (games or others) does it. - Some programmer dude