C++ 文件逐行读入 并按空格分割

#include <iostream>
#include <fstream>
#include <sstream>

using namespace std;

int main()
{
  ifstream in("in.txt");
  string line;
  while (getline(in, line))
  {
    stringstream ss(line);
    string token;
    while (ss >> token)
    {
   // Todo
    }
  }

  in.close();
  return 0;
}

posted @ 2015-06-21 17:01  上帝抬不动的石头  阅读(3629)  评论(1编辑  收藏  举报