#include <iostream>
#include <string>
#include <io.h>
using namespace std;
//文件是否存在
int file_exists(char *filename)
{
return (access(filename, 0) == 0);
}
int main( void )
{
printf("E盘有a.txt文件吗?: %s\n",
file_exists("e:/a.txt") ? "YES" : "NO");
system( "PAUSE" );
return EXIT_SUCCESS;
}
/*--------
E盘有a.txt文件吗?: YES
请按任意键继续. . .
---------------------------------*/access函数测试指定路径中是否有某个文件存在
最新推荐文章于 2023-04-04 16:47:16 发布
本文探讨了如何通过编程实现文件存在性检查,并具体应用到验证E盘上是否存在名为a.txt的文件,提供了实用的代码示例。
240

被折叠的 条评论
为什么被折叠?



