C++--在屏幕上显示指定的文本文件的内容

#include<iostream>
#include<fstream>
using namespace std;
int main()
{

ifstream ifle;
char fn[20],ch;
cout<<"输入文件名:";
cin>>fn;
ifle.open(fn);
if(!ifle)
{
cout<<fn<<"文件不能打开"<<endl;
return 0;
}
while((ch = ifle.get())!=EOF)
cout<<ch;
cout<<endl;
ifle.close();
return 1;
}

猜你喜欢

转载自www.cnblogs.com/zhongxiaozheng/p/12757898.html
今日推荐