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;
}
网友评论