Lines in File

This is a discussion on Lines in File within the C++ Programming forums, part of the General Programming Boards category; How can I determine the number of written lines in a file? Could anyone help? Thanks...

  1. #1
    Unregistered
    Guest

    Lines in File

    How can I determine the number of written lines in a file? Could anyone help? Thanks

  2. #2
    Magically delicious LuckY's Avatar
    Join Date
    Oct 2001
    Posts
    856

    Lightbulb

    Simple:

    string str;
    ifstream fin(FILE);

    int linecount = 0;
    while (fin.good()) {
      getline(fin,str);
      ++linecount;
    }

    That's it.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Data Structure Eror
    By prominababy in forum C Programming
    Replies: 3
    Last Post: 01-06-2009, 08:35 AM
  2. opening empty file causes access violation
    By trevordunstan in forum C Programming
    Replies: 10
    Last Post: 10-21-2008, 11:19 PM
  3. help with text input
    By Alphawaves in forum C Programming
    Replies: 8
    Last Post: 04-08-2007, 04:54 PM
  4. Batch file programming
    By year2038bug in forum Tech Board
    Replies: 10
    Last Post: 09-05-2005, 03:30 PM
  5. Replies: 3
    Last Post: 03-04-2005, 01:46 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21