txt文件内容:
#include#include #include #include #include using namespace std; int main() { vector > data; ifstream infile("D:\桌面文件\test.txt"); while (infile) { string s; if (!getline(infile, s)) break; istringstream ss(s); vector record; while (ss) { string s; if (!getline(ss, s, ',')) break; record.push_back(s); } for (auto x : record) cout << atof(x.c_str()) << " ";//string转double cout << endl; data.push_back(record); } if (!infile.eof()) { cerr << "Fooey!n"; } }
输出:
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)