fgets:获取N个字符,这里是128,或者遇到\n结束,存入l_chANames中。
fopen:输入路径是char*类型
#include <sdtio>
std::map<std::string, vector<int>> Lables;
std::vector<std::string> labels_list;
FILE *pFile = fopen(label_file.c_str(), "r");
bool bRet;
char l_chANames[128];
do
{
bRet = (fgets(l_chANames, 100, pFile) != NULL);
std::string lstrTemp = l_chANames;
if (lstrTemp.size() > 1)
{
l_chANames[lstrTemp.size() - 1] = '\0';
labels_list.push_back(l_chANames);
Lables[l_chANames] = {0, 0};
}
} while (bRet);
fclose(pFile);
文件拷贝:
需要头文件
#include <unistd.h>
#include <fcntl.h>
unistd包含:read,write
fcntl包含: open
fd= open(src_path.c_str(),O_RDWR|O_CREAT);
fd2 = open(des_path.c_str(),O_RDWR|O_CREAT);
while(len = read(fd,buff,1024))
{
write(fd2,buff,len);
}
close(fd);
close(fd2);
https://blog.csdn.net/qq_21197941/article/details/125168151?ops_request_misc=%257B%2522request%255Fid%2522%253A%2522166797400516782425619539%2522%252C%2522scm%2522%253A%252220140713.130102334…%2522%257D&request_id=166797400516782425619539&biz_id=0&utm_medium=distribute.pc_search_result.none-task-blog-2allbaidu_landing_v2~default-1-125168151-null-null.142v63wechat,201v3control,213v2t3_esquery_v2&utm_term=c%2B%2B%20O_RDWR&spm=1018.2226.3001.4187