Data File Handling Solution (SD/4/B/137)

Write a function in C++ to read the content of a text file "HOBBY.TXT" and display all those lines on screen, which are either starting with 'A' or with 'T'.

Solution:

Data File Handling - Text File (SD/4/B/137)


void Display()
{
ifstream fin;
fin.open("HOBBY.TXT",ios::in);
char line[80];
while(!fin.eof())
{
fin.getline(line,80);
if(line[0]=='A' || line[0]=='T')
cout<<line<<endl;
}
}




No comments

Post your comments

Powered by Blogger.