Code::Blocks Forums

Developer forums (C::B DEVELOPMENT STRICTLY!) => Development => Topic started by: Feuer on January 07, 2007, 09:24:38 pm

Title: SDL - output in console doesn't work
Post by: Feuer on January 07, 2007, 09:24:38 pm
Hi there,
I create an new SDL project and everything is fine.
But, if I want an output trough printf or cout, nothing is in the console. Is there anything wrong, is it generally possible?

If you speak german, you can answer me in german :-)

Greetz
Title: Re: SDL - output in console doesn't work
Post by: mandrav on January 07, 2007, 09:51:26 pm
I believe SDL redirects all output intended for stdout/stderr to files stdout.txt/stderr.txt. Check the folder your program runs in for those files.
Title: Re: SDL - output in console doesn't work
Post by: Feuer on January 07, 2007, 10:05:38 pm
yeah, there is it, thanks

is it possible, that sdl redirect it in the console?
Title: Re: SDL - output in console doesn't work
Post by: Phatency on January 07, 2007, 10:21:01 pm
yeah, there is it, thanks

is it possible, that sdl redirect it in the console?
Yes it is, just add the following lines to your code (after SDL_Init)
Code
freopen("CON", "w", stdout); // redirects stdout
freopen("CON", "w", stderr); // redirects stderr
Title: Re: SDL - output in console doesn't work
Post by: Feuer on January 07, 2007, 10:28:38 pm
it works!

thanks
Title: Re: SDL - output in console doesn't work
Post by: thomas on January 08, 2007, 04:55:18 pm
There is an even easier way.... SDL has some constant that you can #define so it does not redirect in the first place. I don't remember what the constant was, but it's in the docs somewhere.
Title: Re: SDL - output in console doesn't work
Post by: Feuer on January 08, 2007, 07:07:07 pm
ok thanks,
I try to find it