分类: LINUX
2006-09-21 17:02:24
freopen( "file.txt", "w", stdout );
freopen( "CON", "w", stdout );
// Compile options needed: none
#include
#include
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");
}
假定该 stdout 是向末尾程序控制台重定向到该程序。
引自: