C++读取txt 文件

来源:互联网 发布:biorad cfx 软件下载 编辑:程序博客网 时间:2024/06/06 03:39

void PrintTableBody(){

ifstream  input ;    //  从文件到程序的流。

input.open("jobs.txt") ;


if( !input.is_open() )    // error checking.

{        

           cerr << "Cannot find the file jobs.txt" << endl;

  //         return -1 ;

}

while(true){              // read from file

int intValue ;

input >> intValue ;

if(input.fail())  break ;

}

input.close() ; 

input.clear()  ;

}




int myInteger ;

fstream  fstr ;

fstr.open("job.txt") ;


fstr  >>  myInteger ;


fstr.close() ;

0 0