skip headers while reading text

Solutions on MaxInterview for skip headers while reading text by the best coders in the world

showing results for - "skip headers while reading text"
Helena
03 May 2020
1#include<sstream>
2...
3
4...
5std::ifstream file {"test.txt"};
6std::string word, line;
7std::istringstream iss;
8double var, tab[100][6];
9int i=0, j;
10...
11
12while(getline(file, line))
13{
14  if (!(line[0]=='#'))
15  {
16    iss.str(line);
17    
18    j = 0;
19
20    while(iss >> var)
21    {
22      tab[i][j] = var;
23      ++j;
24    }
25    
26    iss.clear();
27
28    ++i;
29  }
30}
31
32file.close();
33
similar questions
queries leading to this page
skip headers while reading text