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;
}


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM