📜  阅读文本时跳过标题 - C++ 代码示例

📅  最后修改于: 2022-03-11 14:44:45.243000             🧑  作者: Mango

代码示例1
#include
...

...
std::ifstream file {"test.txt"};
std::string word, line;
std::istringstream iss;
double var, tab[100][6];
int i=0, j;
...

while(getline(file, line))
{
  if (!(line[0]=='#'))
  {
    iss.str(line);
    
    j = 0;

    while(iss >> var)
    {
      tab[i][j] = var;
      ++j;
    }
    
    iss.clear();

    ++i;
  }
}

file.close();