PROGRAM TO PRINT A TEXT FILE ON SCREEN

#include<process.h>
#include<conio.h>
void main()
{
clrscr();
char filename[13];
cout<<“Enter the text file name “;
cin.getline(filename,13);
cout<<“\n”;
ifstream fin;
fin.open(filename);
if(!fin)
{
cerr<<“\n file can’t be opened !\n”;
exit(-1);
}
ofstream fout;
fout.open(“PRN”);
char ch;
while(fin.get(ch)!=0)
fout.put(ch);
getch();
}

Comments

Popular Posts