C++ txt文档读取

void readfile(string filepath){
ifstream myfile;

if (!myfile) {
cout << "打开文件出错!";
exit(1);

}else{
myfile.open(filepath);
string ss;
while(getline(myfile,ss))//着行读取数据并存于s中,直至数据全部读取
{
cout<<ss<<endl;
}
system("pause");
myfile.close();
}
}

posted on 2016-07-14 11:37  Anna-SZ  阅读(170)  评论(0)    收藏  举报

导航