繁体   English   中英

用C打开文件

[英]Fopen a file in C

这是我的代码:

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);
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM