从文本读取一行

#include <fstream>
#include <iostream>
#include<string>

using namespace std;

 

 

std::string tmp;
 std::ifstream infile("d:/aa.txt");
 if ( !infile )
  return;
 while (getline(infile,tmp,'\n'))
 {
  cout<<tmp.c_str()<<std::endl;
 }

 infile.close();

posted @ 2012-12-06 15:29  废弃账号  阅读(110)  评论(0编辑  收藏  举报