How do I keep SDL from outputting stdout to a file?

Started by
13 comments, last by Drakkcon 18 years, 7 months ago
Sorry about the cross-post Oluseyi. It was before I we got your answer. I thought someone in that group might have a good idea.
Advertisement
void ActivateConsole(){    AllocConsole();        HANDLE newConsoleInput = GetStdHandle(STD_INPUT_HANDLE);    HANDLE newConsoleOutput = GetStdHandle(STD_OUTPUT_HANDLE);        int inFd = _open_osfhandle((long)newConsoleInput, _O_TEXT);    int outFd = _open_osfhandle((long)newConsoleOutput, _O_TEXT);        FILE* consoleIn = _fdopen(inFd, "r");    FILE* consoleOut = _fdopen(outFd, "w");        setvbuf(consoleIn, NULL, _IONBF, 0);    setvbuf(consoleOut, NULL, _IONBF, 0);        *stdin = *consoleIn;    *stdout = *consoleOut;}



Here's my console activation function. The only problem is, I still don't get a console [sad]. What I'm probably doing wrong involves HANDLEs probably, since I don't know what a handle is a typedef of. when I use _open_osfhandle(newConsoleInput, _0_TEXT); I get an error: invalid conversion from `void*' to `long int'. I have tried casting it to many things.

Any ideas?
Ah, nevermind! I fixed it, I was forgetting to call my ActivateConsole() function.

Me <--- Embarresed.

Thanks a lot oluseyi, it works!

PS: What is a file descriptor?
Quote:Original post by Drakkcon
PS: What is a file descriptor?

Streams and File Descriptors.
Thanks!

I also found this,
which tells me how to use them.

This topic is closed to new replies.

Advertisement