【发布时间】:2013-12-13 12:26:41
【问题描述】:
我需要知道带有浮点数的文本文件的列数。
为了知道行数我做了这样的:
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
一行.txt:
189.53 58.867 74.254 72.931 80.354
值的数量可能因文件而异,但不能在同一个文件中。
每个值在“.”之后都有可变的小数位数。 (点)
这些值可以用空格或制表符分隔。
谢谢
【问题讨论】:
标签: c++ text-files multiple-columns