1.

Write a user defined function in C++ to read the content from a text file NOTES.TXT, count and display the number of blank spaces present in it.

Answer»

void countspace()

{

 ifstream fins;

 fins.open("NOTES.TXT");

 char ch;

 int count=0;

 while(!fins.eof())

 {

 fin.get(ch);

 if(ch==' ')

 count++;

 }

 cout<<"Number of blank spaces"<<count;

 fin.close();

 }



Discussion

No Comment Found

Related InterviewSolutions