Program to count number of characters in a file

Home Forums C++ Program to count number of characters in a file

This topic contains 0 replies, has 1 voice, and was last updated by  admin 2 weeks, 3 days ago.

Viewing 1 post (of 1 total)
  • Author
    Posts
  • #5251

    admin
    Keymaster

    //Program to count number of characters in a file.

    #include<fstream>
    #include<iostream>
    using namespace std;

    int main()
    {
    ifstream fin;
    fin.open(“out.txt”);

    int count = 0;
    char ch;

    while(!fin.eof())
    {
    fin.get(ch);
    count++;
    }

    cout << “Number of characters in file are ” << count;

    fin.close();
    return 0;
    }

Viewing 1 post (of 1 total)

You must be logged in to reply to this topic.