这是我的代码:
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进行写入时出现问题
我问你是否知道这个错误
谢谢您。
最佳答案
尝试perror()
以更好地描述错误。
if (!outfile) {
/* printf("There was a problem opening %s for writing\n", outname); */
perror(outname);
}