0
我在做一个使用SDL库的项目。在Unix上重定向标准输出
我注意到stdout和stderr被重定向到2个文件:stdout.txt和stderr.txt。
我设法流重定向回Windows平台上,但我不能为Unix平台上做到这一点...
void redirectSDLStreams() {
#ifdef _WIN32
freopen("CONOUT$", "w", stdout);
freopen("CONOUT$", "w", stderr);
#elifdef __unix__ // Not sure about it tho
// Code for Unix
#endif
}
我想:
printf("Ok from stdout\n") // Prints something
freopen("/dev/tty", "w", stdout);
printf("Ok from /dev/tty\n") // Prints nothing
和:
printf("Ok from stdout\n") // Prints something
freopen("/dev/stdout", "w", stdout);
printf("Ok from /dev/stdout\n") // Prints nothing
但都未能在Fedora 17 ...
任何想法?
谢谢!
很高兴知道,谢谢! – user3821901