Program to count number of words in a file.

Home Forums C++ Program to count number of words 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
  • #5250

    admin
    Keymaster

    //Program to count number of words

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

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

    int count = 0;
    char word[30];

    while(!fin.eof())
    {
    fin >> word;
    count++;
    }

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

    fin.close();
    return 0;
    }

Viewing 1 post (of 1 total)

You must be logged in to reply to this topic.