C++读取文本文件
比如有一批坐标点:
我想读取进一个vector数组中,代码片如下:
const char* FileName = "./Resources/Plan.txt";
ifstream readFile;
readFile.open(FileNeedlePos, ios::in);
vector<float> pos;
string str;
while (readFile >> str)
{
str.erase(remove(str.begin(), str.end(), '['), str.end());
str.erase(remove(str.begin(), str.end(), ']'), str.end());
pos.push_back(stof(str));
cout << str << endl;
}
readFile.close();