Page 1 of 1

cout going to stdout.txt

Posted: Sat Dec 20, 2008 1:11 am
by dandymcgee
Does anyone know any reason why using cout << "string"; would be sending "string" the stdout.txt instead of the actual console windows?

If specific program details are needed let me know, but I figure this error is generic enough where maybe I'm just being stupid about something. It is 2:00 AM..

Re: cout going to stdout.txt

Posted: Sat Dec 20, 2008 4:04 am
by cypher1554R
well, did you do this:

Code: Select all

std::ofstream cout("stdout.txt");
cout << "string";
instead of this:

Code: Select all

std::cout << "string";
..?

Re: cout going to stdout.txt

Posted: Sat Dec 20, 2008 5:05 am
by PixelP
if youre coding something in sdl you cant do that, you cant use the console in a sdl program, all the output goes to stdout.txt.
it works in allegro thou.

Re: cout going to stdout.txt

Posted: Sat Dec 20, 2008 10:05 am
by dandymcgee
PixelP wrote:if youre coding something in sdl you cant do that, you cant use the console in a sdl program, all the output goes to stdout.txt.
it works in allegro thou.
But the weird part about it is a console window pops up with a blinking cursor, just the cout text doesn't display. I can still type in the filename and hit enter, then type q and hit enter and the program exits with status 3. Yet my debug output file (not stdout) tells me that the program received the file name and q command fine.

EDIT: I got it to work! Although it took a good bit of googling. Simply add the following line of code after SDL_Init():

Code: Select all

freopen( "CON", "w", stdout ); 
Seems to be working fine for me now.

Re: cout going to stdout.txt

Posted: Sat Dec 20, 2008 10:39 am
by PixelP
great.

Re: cout going to stdout.txt

Posted: Tue Dec 23, 2008 3:41 pm
by MarauderIIC
Interesting, my console worked in my SDL app without any special code.