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