Original Post
I want to use SDL functions in my program, but I also want to be able to use the Command Prompt. Could someone tell me how to allow stdio to use the console window?
Quote:
Original post by Drakkcon
Could someone tell me how to allow stdio to use the console window?
*stdin = *conin;*stdout = *conout;where conin and conout are the FILE *s that correspond to the input and output handles of your console, respectively.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;}void*' to long int'. I have tried casting it to many things.This topic has been locked by a moderator. New replies are not allowed.
With your permission, GameDev.net uses analytics cookies to understand how people use the platform. You can accept analytics or continue with necessary cookies only. Learn more