我需要使用C创建.log文件.但是,我无法使用通常的方法来创建它.文件已创建但无法写入.谁能解释一下?
f = fopen("file.log", "w");
fprintf(f, "print this");
Run Code Online (Sandbox Code Playgroud)
And*_*dro 10
创建.log文件就像在C中创建任何其他文件一样
FILE *f;
f = fopen("x.log", "a+"); // a+ (create + append) option will allow appending which is useful in a log file
if (f == NULL) { /* Something is wrong */}
fprintf(f, "Im logging somethig ..\n");
Run Code Online (Sandbox Code Playgroud)
这几乎是整个魔术.
| 归档时间: |
|
| 查看次数: |
17397 次 |
| 最近记录: |