c++如何读取CSV数据转二维数组

比如CSV数据是:
1,2,3,4,5,6

11,22,33,44,55,66
111,222,333,444,555,666
如何能存到数组,比如a[1][1],就能取到22这样

#include <string>
#include <sstream>
#include <iostream>
int main() {
 std::string str("123,56,34");
 std::stringstream ss(str);
 while (std::getline(ss,str,','))
 {
  std::stringstream s(str);
  double num;
  s >> num;
  std::cout << num << std::endl;
 }
}

你只要搞清楚 std::getline 就可以了

温馨提示:答案为网友推荐,仅供参考
第1个回答  2015-02-12
csv就是文本,用文件流读入,getline
相似回答