How would I do this?

This is a discussion on How would I do this? within the C Programming forums, part of the General Programming Boards category; I have a data file filled with random numbers, I need to read the numbers into an array and count ...

  1. #1
    Registered User
    Join Date
    Apr 2007
    Posts
    11

    How would I do this?

    I have a data file filled with random numbers, I need to read the numbers into an array and count the numbers read. Maybe Im just being an idiot right now, but for some reason I can't think of how to count how many numbers were read. How do I write that?

  2. #2
    Registered User
    Join Date
    Sep 2006
    Posts
    8,868
    That depends on the specific format of the numbers in the file. Are the numbers each on a separate line, or all on the same line. Do they have a space between numbers, or what is used to separate one number from the next?

    Adak

  3. #3
    Deathray Engineer MacGyver's Avatar
    Join Date
    Mar 2007
    Posts
    3,211
    Use a loop. Have a counter variable that is initialized to 0 and increased for every number read. You then have the amount of numbers read.

Popular pages Recent additions subscribe to a feed

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