0

这是我的代码:

outfile = fopen(outname, "w");//outname="/home/user/dir/file"
if (!outfile) {
printf("There was a problem opening %s for writing\n", outname);
}
else {
 /* write to the file, */
 }

运行时显示:打开 /home/user/dir/file 进行写入时出现问题 请问您是否对此错误有任何想法 谢谢。

4

1 回答 1

5

尝试perror()更好地描述错误。

if (!outfile) {
    /* printf("There was a problem opening %s for writing\n", outname); */
    perror(outname);
}
于 2012-09-19T21:45:31.043 回答