Program to count number of lines in a file

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

This topic contains 0 replies, has 1 voice, and was last updated by  admin 7 months, 4 weeks ago.

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

    admin
    Keymaster

    //Program to count number of lines

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

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

    int count = 0;
    char str[80];

    while(!fin.eof())
    {
    fin.getline(str,80);
    count++;
    }

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

    fin.close();
    return 0;
    }

Viewing 1 post (of 1 total)

You must be logged in to reply to this topic.