Jump to content
  • Advertisement
Sign in to follow this  
homeboye

[SDL] how to show output to the console window?

This topic is 4487 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello, how would I change the output from 'stdout' to the console window in win32? EDIT: without using any windows-specific headers/commands/functions. EDIT2: better yet, ppl that have recompiled the SDLmain.a, can you send me the file? ;) [Edited by - homeboye on March 11, 2006 10:08:48 AM]

Share this post


Link to post
Share on other sites
Advertisement
You just need 2 lines of code:

freopen("CON","r",stdin);
freopen("CON","w",stdout);

Works on Windows... dunno on other plataforms.

Share this post


Link to post
Share on other sites
If you are using a version of MS Visual C you would create a console project instead of a win32 project and this sets the right IDE/environment variables where stdout is the console window. Using DevC++ I used the SDL DevPack and the project template it provides and that is the default. I am unsure exactly how to do it manually but I know it is a few settings you can change to your project in your IDE that affect this behavior. I am sure there are examples somewhere for whatever IDE you are using if you look a little bit.

Share this post


Link to post
Share on other sites
SDL 1.2.9 began redirected stdout, and stdin. People must have been complaining about the presence of a console in their applications. You can either re-set the redirecting (ie cancel it out) which is what the "freopen" does. Alternatively you can rebuild SDL so that redirection is disabled .

I prefer the later myself, i believe there is a line in "sdl_win.c[pp]" about WindowsCE (for whic redirection was unsuitable) but I'm not sure, although I remember it being realy obvious what was going on.

[Edited by - Malchivus on March 17, 2006 10:50:59 AM]

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!