how to detect newline in a *txt file

This is a discussion on how to detect newline in a *txt file within the C Programming forums, part of the General Programming Boards category; Dear All, I have one txt file which contains a set of data, everyline has one data. How can I ...

  1. #1
    Registered User
    Join Date
    Oct 2003
    Posts
    38

    how to detect newline in a *txt file

    Dear All,
    I have one txt file which contains a set of data, everyline has one data. How can I detect how many data inside?
    Thank you

  2. #2
    Registered User Azuth's Avatar
    Join Date
    Feb 2002
    Posts
    236
    Likely you can read the file line by line. Lines will probably be seperated by the character '\n', write a loop to count how many of these your file has.
    Demonographic rhinology is not the only possible outcome, but why take the chance

  3. #3
    Registered User
    Join Date
    Oct 2003
    Posts
    38
    thank you.
    I know this method, but I don't the code. Sorry, I am the new user of C/C++.

  4. #4
    Been here, done that.
    Join Date
    May 2003
    Posts
    1,161
    Do you know how to read a file? Look up fopen(), fclose() and fgets() if not.
    Definition: Politics -- Latin, from
    poly meaning many and
    tics meaning blood sucking parasites
    -- Tom Smothers

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Problems passing a file pointer to functions
    By smitchell in forum C Programming
    Replies: 4
    Last Post: 09-30-2008, 03:29 PM
  2. Game Pointer Trouble?
    By Drahcir in forum C Programming
    Replies: 8
    Last Post: 02-04-2006, 02:53 AM
  3. Possible circular definition with singleton objects
    By techrolla in forum C++ Programming
    Replies: 3
    Last Post: 12-26-2004, 10:46 AM
  4. System
    By drdroid in forum C++ Programming
    Replies: 3
    Last Post: 06-28-2002, 11:12 PM
  5. Hmm....help me take a look at this: File Encryptor
    By heljy in forum C Programming
    Replies: 3
    Last Post: 03-23-2002, 10:57 AM

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