综述
一个cpp的文件读取模版。
库
#include <fstream>
#include <string>
代码
string selected_poles_path = "/Users/frankdura/Desktop/a.txt";
//set the file path
ifstream in(selected_poles_path);
// init
while( in >> label ){ // identify the selected poles!
//reading
if(label == "v"){
in >> pole_x >> pole_y >> pole_z;
cout << pole_x << " " <<pole_y <<" " <<pole_z<< endl;
vector<int> pole;
pole.push_back(pole_x);
pole.push_back(pole_y);
pole.push_back(pole_z);
selected_poles_con.push_back(pole);
}
}
in.close();