Write a C++ Program to create and display a text file. In case, number of lines exceeds 22. File should be displayed on screen at a time.

#include<fstream.h>
#include<stdio.h>
#include<ctype.h>
#include<stdlib.h>

void ReadFile()
{
char filename[20], line[80];
int c=0;
system("cls");
system("dir/w *.txt");
cout<<"Enter the filename you want to read : ";
cin>>filename;
ifstream fin(filename,ios::in);
cout<<"The File: "<<filename<<"contains.....\n";
while(!fin.eof())
{
fin.getline(line,80,'\n');
cout<<line<<endl;
c++;
if(c%22==0)
{
cout<<endl;
system("pause");
}
}
fin.close();
cout<<"\n\nThe file :"<<filename<<" reading completed....\n";
system("pause");
}

void main()
{
ReadFile();
}



//Output Screen Shot (Depends on text file you have in PC.












No comments

Post your comments

Powered by Blogger.