How can I get console output instead of stdout.txt and stderr.txt?

SDL_Init() routes stdout and stderr to the respective files. You can revert this by adding the following lines after the call to SDL_Init in your code:

freopen( "CON", "w", stdout );
freopen( "CON", "w", stderr );



#include <fstream>
#include <iostream>
using namespace std;
....
ofstream ctt("CON");
freopen( "CON", "w", stdout );
freopen( "CON", "w", stderr );
...
ctt.close();

FILE * ctt = fopen("CON", "w" );
freopen( "CON", "w", stdout );
freopen( "CON", "w", stderr );
...
ctt.close();

These options may work better since "freopen" implies that the "file" (in this case, the console) is already open and it may not be.



If that doesn't work, another option is to recompile libSDLmain.a. The easiest way to do so is by using MinGW and MSYS:

mount c:/mingw /mingw

$ cd /c/SDL-1.2.9
$ ./configure --disable-stdio-redirect
$ cd src/main
$ make


FAQ_Console (last edited 2010-05-31 21:02:44 by w3cache)