いつもの作業の備忘録

作業を忘れがちな自分のためのブログ

2016-02-21から1日間の記事一覧

【C++】CSV形式を要素ごとに分割

CSVの行(文字列)を要素ごとに分割してvectorで受け取る。 vector<string> split(string str, char c){ vector<string> v; string buf = ""; stringstream ss; ss << str; while (getline(ss, buf, c)){ v.push_back(buf); } return v; } サンプルコード #include <iostream> #include <string></string></iostream></string></string>…