# SDL console window questions

## Recommended Posts

Hello I'm programming various SDL applications during these holidays. My IDE of choice is Code::Blocks. I use the default SDLapp template to create my applications. I've noticed that when I run my compiled program (under Windows at least), not only my SDL window is opened, but also a console. I have two questions:
• I'd like to keep these consoles for now, but I want to display debug information in them. How can I access the console?
• I'd also like to get rid of the console once I feel my application is mature enough to be sent to my friends. I don't want to be responsible for making their heads explode because they saw a console window ;) How do I get rid of the console?
Thanks in forward

##### Share on other sites
Quote:
 Original post by c4c0d3m0nI'd like to keep these consoles for now, but I want to display debug information in them. How can I access the console?

std::cout or printf should do it.

Quote:
 Original post by c4c0d3m0nI'd also like to get rid of the console once I feel my application is mature enough to be sent to my friends. I don't want to be responsible for making their heads explode because they saw a console window ;) How do I get rid of the console?

Under Visual Studio there is an option of Win32 Console Application or Win32 Application. Choosing the former creates a console while the latter doesn't. I don't know if Code::Blocks has such an option, but you may want to look in you project settings.

##### Share on other sites
Quote:
Original post by Simian Man
Quote:
 Original post by c4c0d3m0nI'd like to keep these consoles for now, but I want to display debug information in them. How can I access the console?

std::cout or printf should do it.

std::cout tells me that 'cout' is not part of 'std'. printf writes into a textfile called 'stdout.txt'. Neither outputs anything to the console.

Quote:

Quote:
 Original post by c4c0d3m0nI'd also like to get rid of the console once I feel my application is mature enough to be sent to my friends. I don't want to be responsible for making their heads explode because they saw a console window ;) How do I get rid of the console?

Under Visual Studio there is an option of Win32 Console Application or Win32 Application. Choosing the former creates a console while the latter doesn't. I don't know if Code::Blocks has such an option, but you may want to look in you project settings.

I found said option in the project options, thanks. Is there any preprocessor command that would archieve the same? I'd love to be able to do something like this:
#define DEBUG#ifndef DEBUG  // Get rid of the console#endif

##### Share on other sites
you are probably running on /SUBSYSTEM:CONSOLE

in MSVC++ you would do the following:
and change from Console to Windows

##### Share on other sites
Code::Blocks gets rid of the console window when
setting the build target as Release (atleast for me).

And you need to include iostream to use cout.

##### Share on other sites
Quote:
 Original post by c4c0d3m0nstd::cout tells me that 'cout' is not part of 'std'. printf writes into a textfile called 'stdout.txt'. Neither outputs anything to the console.

##### Share on other sites
Quote:
Original post by Simian Man
Quote:
 Original post by c4c0d3m0nstd::cout tells me that 'cout' is not part of 'std'. printf writes into a textfile called 'stdout.txt'. Neither outputs anything to the console.

Ah thanks, the link you provided gave me the answer! Thanks again

##### Share on other sites
    freopen( "CON", "w", stdout );    freopen( "CON", "w", stderr );

Hmm, those lines of code enable output to the console, but only when I run my program from the console. If I run my program through explorer, a console window is created, but it stays empty. How do I gain access to this console aswell?

## Create an account

Register a new account

• ## Partner Spotlight

• ### Forum Statistics

• Total Topics
627660
• Total Posts
2978489

• 10
• 12
• 22
• 13
• 33