Author Topic: SDL - output in console doesn't work  (Read 16400 times)

Feuer

  • Guest
SDL - output in console doesn't work
« 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

Offline mandrav

  • Project Leader
  • Administrator
  • Lives here!
  • *****
  • Posts: 4315
    • Code::Blocks IDE
Re: SDL - output in console doesn't work
« Reply #1 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.
Be patient!
This bug will be fixed soon...

Feuer

  • Guest
Re: SDL - output in console doesn't work
« Reply #2 on: January 07, 2007, 10:05:38 pm »
yeah, there is it, thanks

is it possible, that sdl redirect it in the console?

Offline Phatency

  • Multiple posting newcomer
  • *
  • Posts: 65
Re: SDL - output in console doesn't work
« Reply #3 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

Feuer

  • Guest
Re: SDL - output in console doesn't work
« Reply #4 on: January 07, 2007, 10:28:38 pm »
it works!

thanks

Offline thomas

  • Administrator
  • Lives here!
  • *****
  • Posts: 3979
Re: SDL - output in console doesn't work
« Reply #5 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.
"We should forget about small efficiencies, say about 97% of the time: Premature quotation is the root of public humiliation."

Feuer

  • Guest
Re: SDL - output in console doesn't work
« Reply #6 on: January 08, 2007, 07:07:07 pm »
ok thanks,
I try to find it