不打印csv文件c ++的第二列

时间:2017-10-10 22:42:30

标签: c++ parsing

std::ifstream file_stream1(outfile,std::ifstream::out | std::ifstream::binary);
    std::vector<double> file;
     std::vector<double> file1;
    std :: string line;
    while (getline (file_stream1, line))
    {

        double item[100];
        std :: string dataEntry; //a particular entry as a string

        std :: istringstream lineStream(line);

        for(int i = 0; i < 1; i++)
        {
            //get one entry
            getline( lineStream, dataEntry, ',');
            lineStream >> std::ws; //remove whitespace after the comma and before the next entry

            std:: istringstream( dataEntry ) >> item[i];
            std :: cout << item[i] << std ::endl ;
            file.push_back (item[i]);
            file1.push_back (item[i]);

        }
  1. 我正在尝试读取csv文件c ++,我有两列所有双数据,但问题是它只打印第一列吗?

1 个答案:

答案 0 :(得分:0)

你的for循环只有一次迭代,使用:

for(int i = 0; i&lt; = 1; i ++)