我需要知道浮动文本文件的列数。知道文本文件的列数,用空格或制表符分隔
我做了这样知道的行数:
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的A线:
189.53 58.867 74.254 72.931 80.354
值的数量可以从文件中有所不同的文件,但不在同一个文件上。
每个值在“。”后面都有一个可变的小数位数。 (dot)
这些值可以用空格或TAB分隔。
谢谢
我得到了一个错误: 错误:函数计数(dummyLine.begin(),dummyLine.end (),'\ t')没有在当前范围中定义 您可以指定count()吗? – JMG
在文件的顶部,这个代码在'#include' –
我正在使用root,我不能使用所有的C++功能,并且出现同样的错误... – JMG