首页 > 编程语言 > 详细

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

时间:2015-06-21 18:21:03      阅读:675      评论:0      收藏:0      [点我收藏+]

#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;
}

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

原文:http://www.cnblogs.com/chinesedream/p/4592125.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!