Home » questions » How to input a series of numbers in a text file into an array?

How to input a series of numbers in a text file into an array?

2006-08-03 15:04:00, Category: Programming & Design
My data is a series of numbers in several rows e.g. 1 2 3 4 5 6 I want to read the numbers one by one and then place them in the same order in an array. I was thinking of using C or VB to do this. Which is faster to code?

Answers

  1. Proud Muslim

    On 2006-08-03 15:08:57


    That all depends on what language you are familiar with in the first place. I have never used VBasic, so I would use C, with heavy emphasis on the 'fscanf' library call. It would be quite simple to accomplish, really.
  2. Martyr2

    On 2006-08-03 15:58:41


    Both languages can do an operation like this at about the same speed. Depending on your experience with each of these languages, I would go with whatever is the most comfortable. As a design suggestion, make a matrix or jagged array and load the numbers in where you can access them by coordinates. Then you could load them up and retrieve them with a nested loop.