一些我记不住的东西

        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各位大神路过就好。

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值