Sunday, 13 March 2016

Write A C++ Program For Count A Character In File Using File

#include <iostream>
#include <fstream>
#include <string>

using namespace std;
char FileName[] = "example.txt";
//Ghanendra Yadav
int main ()
{
string line;
ifstream inMyStream (FileName);
int c;

if (inMyStream.is_open())
{

     while(  getline (inMyStream, line))
{

             cout<<line<<endl;
             c += line.length();
           
     }
     cout<<"\n\n"<<"Total Character In File "<<c<<endl<<endl;
    }
    inMyStream.close();

system("pause");
   return 0;
}

Input:-



Output:-


No comments:
Write comments

Recommended Posts × +