2017-10-10 145 views
-1
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++,我都雙倍數據的兩列第二列,但問題是它僅打印第一列?
+0

請張貼[MCVE]。 – melpomene

回答

0

你的for循環僅具有一個迭代中,使用:

對(INT I = 0;我< = 1;我++)

+0

我試過了,但沒有解決問題。 –