c++如何读取包含多列不同类型数据的txt文件
txt文件格式如下:score1 11.2 score2 10.1
score3 11.2 score4 10.1
score5 11.2 score6 10.1
... ....
就是字符串 空格 数字的形式,总行数不定。
想要实现的是读入txt中的各列数字到数组中,并进行排序。
只是不知道怎么读
用ifstream + getline只能把每行读成一个字符串,不能直接读到数组中
这个有没有比较成熟的方法?
string str; ifstream in; while(in>>str) //或者 while (in >> str, in)