This topic is now archived and is closed to further replies.


using iostream.h before SDL

Recommended Posts

BioSquirrel    122
I am making an SDL program and I want to recieve some information before it starts in an MSDOS window (using cin). It doesn''t seem to go to the DOS window, it just starts the SDL''s the code. int main(int argc, char *argv[]) { cout << "Enter Player1''s name:\n"; cin >>; Uint8* keys; //SDL starts here... The program skips past the cout and cin commands... ------------------ Stupid Morons- my current projects

Share this post

Link to post
Share on other sites
Fruny    1658
Do NOT use <iostream.h>, it is a deprecated header.

Use <iostream> instead, even if it require you to type using namespace std; at the beginning of your source files and to qualify all class names with std:: in your header files.

Now, to answer your question, SDL redirects cin, cout and cerr to files when it starts ("stdout.txt" and "stderr.txt" IIRC, you may have to provide "stdin.txt" yourself or pipe it into your app). There may be options to disable that. Read the SDL source code to find out (yes, it's available!), if it is not documented.

[Questions (STFW) | GDNet Start Here | GDNet Search | Forum FAQ | Google | Asking Smart Questions ]
[Docs (RTFM) | MSDN | SGI's STL | OpenGL | File formats]
[C++ Must Haves (RTFS) | MinGW | Boost | Loki | FLTK | SDL ]

Stolen from Magmai Kai Holmlor, who held it from Oluseyi, who was inspired by Kylotan...

[edited by - Fruny on May 6, 2002 5:32:50 PM]

[edited by - Fruny on May 6, 2002 5:40:45 PM]

Share this post

Link to post
Share on other sites
Solstice    122
As far as I know, that redirection is present only under Windows. Linux seems fine with redirecting output to the console, but not windows.

You may also want to concider SDL_Console present on the libraries page on It''s not as clean as cout, but you can avoid file outputing entirely then.


"...I was given three choices, the earth, the stars, or..."

Share this post

Link to post
Share on other sites