AllocConsole() und cout
-
Salve,
um während der Entwicklung einer Windowsanwendung mal schnell ein paar Werte überprüfen zu können, dachte ich mir, ich könne mit AllocConsole() und cout arbeiten.
AllocConsole() erzeugt auch eine Konsole, aber cout gibt nichts darauf aus.
Was muß ich dafür tun?
-
du musst erst alle kanäle auf die neue konsole leiten
#include <io.h> #include <fcntl.h> void snyc_with_console() { int fh = open("CON", _O_WRONLY); *stdout = *fdopen(fh, "w"); setvbuf(stdout, 0, _IONBF, 0); fh = open("CON", _O_RDONLY); *stdin = *fdopen(fh, "r"); setvbuf(stdin, 0, _IONBF, 0); cout.sync_with_stdio(); cin.sync_with_stdio(); }
-
diese frage kommt auch jeden monat einmal.

-
-
Wenns nur zum debuggen ist, nimm doch OutputDebugString()