C++如何读取txt文件,文件比较大想一行一行的读。

==========================

#include   <fstream>  
  #include   <string>  
  //   ..  
  string   filename;       //   the   file   name   you   want   to   open  
  string   lines;         //   store   the   file   lines  
   
  //   ...  
  ifstream   in(filename);  
  if   (in)   {  
        while   (getline   (in,   lines))     //   have   no   '/n',  
      {    
            //   ;  
          //   store   the   lines   to   a   vector   or   list,   use   method   insert  
        }  
   
  //   ...  
  }  
  else  
  {  
        //   open   file   fail....  
  }

========================= =

ifstream   OpenFile("a.txt");  
  OpenFile.getline(String,"/n",size);  
  OpenFile.close();

================================

你可能感兴趣的:(C++,String,vector,list,File,insert)