我会做这样的事情:
ifstream f("data.txt");string str;while (getline(f, str)) { Point p; sscanf(str.c_str(), "%f, %f, %fn", &p.x, &p.y, &p.z); points.push_back(p);}x,y,z必须为浮点数。
包括:
#include <iostream>#include <fstream>

我会做这样的事情:
ifstream f("data.txt");string str;while (getline(f, str)) { Point p; sscanf(str.c_str(), "%f, %f, %fn", &p.x, &p.y, &p.z); points.push_back(p);}x,y,z必须为浮点数。
包括:
#include <iostream>#include <fstream>