1     ifstream fin(file); //打开文件流操作
 2     string line;
 3     int nums_data = 0;
 4     while (getline(fin, line))   //整行读取,换行符“\n”区分,遇到文件尾标志eof终止读取
 5     {
16         istringstream sin(line); //将整行字符串line读入到字符串流istringstream中
17         vector<string> fields; //声明一个字符串向量
18         string field;
19         while (getline(sin, field, '\t')) //将字符串流sin中的字符读入到field字符串中,以逗号为分隔符
20         {
21             fields.push_back(field); //将刚刚读取的字符串添加到向量fields中
22         } 25         int a1= std::stoi(fields[0]);31     }

 

posted on 2021-09-03 17:51  祥祥好帅啊  阅读(304)  评论(0)    收藏  举报