C++中将csv文件中的数据存储到数组中

    xiaoxiao2021-03-25  113

    ifstream fin(filename.c_str());//以输入方式打开文件存到缓冲空间fin中 string line; int i=0; int comma=0; while(getline(fin,line))//读取fin中的整行字符存在line中 { int comma=line.find(',',0); float A[i]=atof(line.substr(comma+1,line.length()-comma-1).c_str()); //将line中的相应位置的字符串转换成float类型放在数组中 i++; }
    转载请注明原文地址: https://ju.6miu.com/read-18178.html

    最新回复(0)