Jump to content
  • Advertisement
Sign in to follow this  
NamelessTwo

How to output text to the console with SDL?

This topic is 4857 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

If I use SDL and try this: cout << "some text to the console"; it is redirected to "stdout" file. Is there a proper way to output to the console instead to a file when using SDL? I only have found this: #ifdef main #undef main #endif but I cannot find anywhere any evidence if it is a proper and reliable way to do it.

Share this post


Link to post
Share on other sites
Advertisement
Quote:
Original post by NamelessTwo
If I use SDL and try this:

cout << "some text to the console";

it is redirected to "stdout" file.

Is there a proper way to output to the console when using SDL? I only have found this:

#ifdef main
#undef main
#endif

but I cannot find anywhere any evidence if it is a proper and reliable way to do it.


the #ifdef/ #undef main thing is because of the way SDL handles windowing on some platforms. it needs to run its own version of WinMain or main to do a bit of setup.

there are functions to open a Console on windows, if thats what you're using. i don't know them though...

Share this post


Link to post
Share on other sites
I'm using Windows and Linux but Linux is my primary target, although I'm currently on Windows.

:) I'd like to not use any platform specific functions if possible.

Share this post


Link to post
Share on other sites
Quote:
Original post by NamelessTwo
I'm using Windows and Linux but Linux is my primary target, although I'm currently on Windows.

:) I'd like to not use any platform specific functions if possible.


if you're in linux and you run the program from the console, IIRC the output goes straight to the console...

for windows you have to do work, somehting like ToohrVyk mentioned

Share this post


Link to post
Share on other sites
Quote:
Original post by SiCrane
Just recompile the project as a console project instead of a windows project.


AFAIK unless SDL is compile with the NO_REDIRECT_STDIO flag (or somthing like that ), it wont work.

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.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!