Text in .txt file and count the No# of string.

#include<iostream>

#include<fstream>

#include<string>

#include<cstdio>

using namespace std;

int main()

{

       int line = 0;

       string Word;

       fstream filing;

       filing.open("story.txt", ios::in);

       if (!filing)

       {

              cout << "File Does Not Exist" << endl;

       }

       else

       {

              cout << "File Is Create Successfully " << endl;

              while (!filing.eof())

              {

                     getline(filing, Word);

                     line++;

              }

              cout << endl << "Total Lines =  " << line << endl;

       }

      

       system("pause");

}






Comments

Popular Posts