mercredi 19 avril 2017

Unable to display the first column

Hello i just get some data from a file but it is very weird becuase i can't get the first column of the text file. This is my text file :

1.2 2.6 3.5
1.02 3.05 4.65
7.15 0.54 9.26 

Here is my code :

#include <iostream>
#include <fstream>

int main(){
std::ifstream myFile("a.txt");
std::string line;
while(std::getline(myFile, line)){

std::string col1, col2, col3;
myFile >> col1, col2 >> col3;
std::cout << col1 << " " << col2 << " " << col3 << std::endl;
}
return EXIT_SUCCESS;
}

So i don't understand why i can't see in the terminal when i execute the program :

1.2 2.6 3.5
1.02 3.05 4.65
7.15 0.54 9.26 

Instead i see this :

1.02 3.05 4.65
7.15 0.54 9.26 

Thank you a lot !

Aucun commentaire:

Enregistrer un commentaire