Thread: Lines in File

  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, 09: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, 02:46 PM