MENU
Question -

Write a function in C++ to read the content of a text file тАЬPLACES.TXTтАЭ and display all those lines on screen, which are either starting with тАШPтАЩ or starting with тАШSтАЩ.



Answer -

void disp ()
┬а{
┬аifstream FILE("PLACES.TXT");
┬аint CA=0;
┬аchar LINE [80];
┬аwhile(FILE.getline(LINE,80))
┬аif(LINE[0]=='P' | | LINE[0]=='S')
┬аputs(LINE);
┬аFILE.close();
┬а}

Comment(S)

Show all Coment

Leave a Comment

Free - Previous Years Question Papers
Any questions? Ask us!
×