Problem with the console (using freopen("CON", "w", stdout))

Hello

When i use freopen(“CON”, “w”, stdout) my console gets… “messed up”,
Oddly i am able to resize the console like a normal window,

These things happen when i use conssole mode with the codeblocks “pause when execution ends” feature:
when i try to invoke a system pause and i press a key, and instead of making a newline, it just creates a strange character (which i cant identify) in the same line (it does resume processing tho). Another thing is that the execution never gets to the part where it pauses, so the console never disapears.

When i dont have the “pause when execution ends” feature, i cant even see the input being sent to the console :\

In a nutshell the thing is a mess :
I tried to solve it by adding #undef main at the begining of my main definition (of course) and that resolved the problem, but i dont know if that is healthy or not.

So what am i doing wrong here?
And is it safe to #undef main ?

Thanks for the atention

Hi.

What is your high level goal?

What platforms do you target? If you #undef main, you end up writing
your own entry point and not using SDL’s platform specific entry
point. To see what SDL’s entry point does for you, see the files here
http://hg.libsdl.org/SDL/file/819e85555d4d/src/main

Have you looked at http://www.libsdl.org/cgi/docwiki.cgi/FAQ_Console,
specifically the section about recompiling SDL_main?

Regards,
– BrianOn 8 September 2011 03:20, ShiroAisu wrote:

Hello

When i use freopen(“CON”, “w”, stdout) my console gets… “messed up”…