I need to know the number of columns from a text file with floats.
I've made like this to know the number of lines:
inFile.open(pathV);
// checks if file opened
if(inFile.fail()) {
cout << "error loading .txt file for reading" << endl;
return;
}
// Count the number of lines
int NUMlines = 0;
while(inFile.peek() != EOF){
getline(inFile, dummyLine);
NUMlines++;
}
inFile.close();
cout << NUMlines-3 << endl; // The file has 3 lines at the beginning that I don't read
A line of the .txt :
189.53 58.867 74.254 72.931 80.354
The number of values can vary from file to file but not on the same file.
Each value have a variable number of decimal places after the "." (dot)
The values can be separated by a space or a TAB.
Thank you