Write a function in C++ to read the content of a text file “DELHI.TXT” and display all those lines on the screen, which are either starting with ‘D’ or starting with ‘M’.
#include<fstream.h>
#include<conio.h>
int main()
{
ifstream fin;
fin.open('out.txt');
char str[80];
int count=0;
clrscr();
while(!fin.eof())
{
fin.getline(str,80);
if(str[0]=='D' || str[0]=='M')
{
cout<<str<<endl;
}
count++;
}
cout<<'Number of lines in file is '<<count; fin.close();
getch();
return 0;
}