using iostream.h before SDL
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 window...here''s the code.
int main(int argc, char *argv[])
{
cout << "Enter Player1''s name:\n";
cin >> Player1.name;
Uint8* keys; //SDL starts here...
The program skips past the cout and cin commands...
------------------
Stupid Morons- my current projects
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]
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]
It worked fine in another program that I made and I checked the code to make sure it looked the same...
------------------
Stupid Morons- my current projects
------------------
Stupid Morons- my current projects
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 libsdl.org. It''s not as clean as cout, but you can avoid file outputing entirely then.
-Solstice
deninet.com
aeris.deninet.com
"...I was given three choices, the earth, the stars, or..."
You may also want to concider SDL_Console present on the libraries page on libsdl.org. It''s not as clean as cout, but you can avoid file outputing entirely then.
-Solstice
deninet.com
aeris.deninet.com
"...I was given three choices, the earth, the stars, or..."
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement