c++ 判断文件是否存在

2019-12-19  本文已影响0人  送分童子笑嘻嘻

include<iostream>

include <thread>

include <string>

include <unistd.h>

include <stdio.h>

include <string.h>

using namespace std;
int FileExist(const char* fname)
{
return access(fname,0);
}
int main() {
string my_string = "/home/cai/bag/test1218bag/bag_opencv_main/config2.txt";
char buf[1000];
strcpy(buf , my_string.c_str());//字符串转字符数组,使用strcpy
int x = FileExist(buf);
std::cout<<x <<std::endl;
return 0;
}

上一篇下一篇

猜你喜欢

热点阅读