我正在尝试在 C 应用程序中打开文件。在尝试读取文件之前如何检查文件是否存在?
尝试打开它:
FILE * file;
file = fopen("file_name", "r");
if (file){
//file exists and can be opened
//...
// close file when you're done
fclose(file);
}else{
//file doesn't exists or cannot be opened (es. you don't have access permission)
}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)