很多介绍怎么重定向到别的文件的,但好少定回来的。
其实很简单啊....内牛满面...
python中
sys.stdout = sys.__stdout__;
sys.stderr = sys.__stderr__;
c++中windows版为:
freopen( "CON", "w", stdout ); (参见链接http://support.microsoft.com/kb/58667/zh-cn)
linux应该为
freopen( "/dev/tty", "w", stdout );
#include <stdio.h> #include <stdlib.h> void main(void) { FILE *stream ; if((stream = freopen("file.txt", "w", stdout)) == NULL) exit(-1); printf("this is stdout output/n"); stream = freopen("CON", "w", stdout); printf("And now back to the console once again/n"); }