Thread: determining how many integers are in an unknown file?

  1. #1
    Registered User
    Join Date
    Jan 2012
    Posts
    39

    determining how many integers are in an unknown file?

    Hi

    Im trying to read in a txt file but i need i need to know how many lines there are in it before i set my array size,

    Do we have a C function that will go off an read how many lines there are in the code?

    I was thinking of using frets and incrementing a count every time frets returns but that means i have to run it in a loop which still restricts me to a max size

    How to i figure out how many lines are in a file with knowing nothing else?

    basically i need to read a file of unknown size that can be any size and determine how many lines are in it

    Any ideas?
    Last edited by automagp68; 04-23-2012 at 12:48 PM.

  2. #2
    Registered User
    Join Date
    Jan 2012
    Posts
    39
    nevermind im retarded i know how

    Thanks always

  3. #3
    Registered User
    Join Date
    Dec 2006
    Location
    Canada
    Posts
    3,229
    Or you can make a buffer, and realloc when ever you fill it up.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. how to get unknown no. of integers from a file
    By getanshub4u in forum C Programming
    Replies: 2
    Last Post: 12-26-2011, 03:38 AM
  2. Problems Reading Line With Unknown Number of Integers
    By envec83 in forum C Programming
    Replies: 3
    Last Post: 09-27-2011, 11:20 AM
  3. Calculating Sum of Integers of Unknown Length
    By egnorth in forum C++ Programming
    Replies: 3
    Last Post: 10-28-2010, 04:31 PM
  4. read unknown integers from text file
    By underlink in forum C Programming
    Replies: 2
    Last Post: 11-10-2009, 10:23 AM
  5. Determining order from a list of integers...
    By AngKar in forum C Programming
    Replies: 12
    Last Post: 04-23-2006, 03:53 PM