c语言将输出重定向到文件中
代码:
#include <stdio.h>
int main()
{
if(freopen("/home/jean/桌面/test.txt","w",stdout) == NULL)
fprintf(stderr,"redirect error!\n");
printf("Hello, I will output this in another file!\n");
return 0;
}
代码:
#include <stdio.h>
int main()
{
if(freopen("/home/jean/桌面/test.txt","w",stdout) == NULL)
fprintf(stderr,"redirect error!\n");
printf("Hello, I will output this in another file!\n");
return 0;
}