数据格式
-53.883533,55.133049,895.801941
-40.928612,32.402653,897.237793
代码:
fstream fs;
fs.open("E:\\wokspace\\PROJECT\\ThirdTrailInspection\\matlab\\dResult.txt");
if (!fs.is_open())
{
return;
}
vector<double> dx;
vector<double> dy;
vector<double> dz;
int i = 0;
string buff;
while (getline(fs, buff))//是否到文件结bai尾
{
int nfist = buff.find_first_of(',');
int nLast = buff.find_last_of(',');
dx.push_back(stod(buff.substr(0, nfist)));
dy.push_back(stod(buff.substr(nfist + 1, nLast - nfist - 1)));
dz.push_back(stod(buff.substr(nLast + 1)));
}
fs.close();
可以参考https://blog.csdn.net/sinat_35821976/article/details/79412090