c++向txt写东西:
//open .txt
ofstream outfile;outfile.open("myfile.txt"); //myfile.txt是存放数据的文件名
if (outfile.is_open())
{
outfile << "href=1'b0;" << endl;
outfile.close();
}
else
{
cout<<"you ci ke "<<endl;
}
c++写csv文件
//定义文件输出流
ofstream oFile;
//打开要输出的文件
oFile.open("score_max.csv", ios::out | ios::trunc);
oFile << "文件名" << "," << "方法" << "," << "x" << "," << "y" << endl;
oFile << " you ci ke"<< endl;
c++读csv文件
ifstream file("score_max.csv"); // declare file stream:
while (file_.good())
{
string value;
// read a string until next comma:
getline(file_, value);
//value就是csv文件的每一行;
}
c++遍历文件夹
//遍历文件夹下的图片
string fileFolderPath = "\pupil-images";
string fileExtension = "jpg";
string fileFolder = fileFolderPath + "\\*." + fileExtension;
// 遍历文件夹
char fileName[2000];
// 文件信息结构体
struct _finddata_t fileInfo;
// 1. 第一次查找
long findResult = _findfirst(fileFolder.c_str(), &fileInfo);
if (findResult == -1)
{
_findclose(findResult);
return -1;
}
// 2. 循环查找
int ij = 0;
do
{
sprintf_s(fileName, "%s\\%s", fileFolderPath.c_str(), fileInfo.name);
if (fileInfo.attrib == _A_ARCH) // 是存档类型文件
{
str[ij] = fileName; //将文件的命称都存到str数组中
ij++;
}
}
while (!_findnext(findResult, &fileInfo));
_findclose(findResult);
要想人不知,除非己末为,所以我也是从网上找到的,自己又懒得记,so各位大神路过就好。