我输出到stdout.如何通过代码将其重定向到新文件?当我们运行程序时,我们可以重定向./sample > test.txt
.如何在执行示例程序时执行此操作?(C编程)
你可能想用freopen.
参考示例:
#include <stdio.h>
...
FILE *fp;
...
fp = freopen ("/tmp/logfile", "a+", stdout);
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
5534 次 |
最近记录: |