C++/SDL: Working console

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Adam01
    New Member
    • Aug 2008
    • 83

    #1

    C++/SDL: Working console

    Does anyone here know how to make the a working console when using SDL.
    I only managed to get it working when running from cmd, when I execute the app, it displays a console box, but text does not display.

    I found this code that creates the console box and stops SDL writing stdout:
    Code:
    freopen("CON", "w", stdout);
    freopen("CON", "w", stderr);
    But does anyone know how make the console box display text when run from a .exe?
  • Adam01
    New Member
    • Aug 2008
    • 83

    #2
    Does anyone use SDL here? (Bump)

    Comment

    • TamusJRoyce
      New Member
      • Apr 2008
      • 108

      #3
      A lot of use do. But we use it so much, we don't visit this forum nearly enough. That's how good it is :P

      It's a compiler/platform specific problem in having the console come up.

      You can do it the hard way and include "windows.h, " and use windows speicific api to open up the console.

      As for mingw, include as a compiler directive -mconsole for a console. For a window it's -mwindow. both it's -mconsole -mwindow. Search about this to be sure.

      For visual c++, I'm sure it's in the ide or there may be a compiler directive. You'd have to search.

      But this specific question is kinda tough to answer since it isn't sdl related, which is why no one has probably answered about this so long.

      Comment

      • Adam01
        New Member
        • Aug 2008
        • 83

        #4
        That creates a console window, but no output is displayed on it.

        Comment

        • oler1s
          Recognized Expert Contributor
          • Aug 2007
          • 671

          #5
          http://forums.codeblocks.org/index.p...prev_next=next Google a bit more. (Or to be precise, just throwing random code snippets won't help, the code there works on the C STDOUT and STDIN fds). You are probably using std::cout, so you can't write the same code.

          You'll come across ideas like: http://www.williamwilling.com/blog/?p=74

          Comment

          Working...