1 Replies - 1261 Views - Last Post: 28 January 2010 - 04:17 PM Rate Topic: -----

#1 brianmen   User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 39
  • Joined: 14-June 09

Help with reading data from a .txt file into an array

Post icon  Posted 28 January 2010 - 04:00 PM

Hello everyone. I'm new to C and was hoping to make a moderately complex program... However, in order to manipulate my input data, I would like to read in data from a text file into an "array". The numbers will be in the text file as follows.

6.35 -24.5 5 -53.3 172

However, I may want to use different text files of different amounts of numbers. Can someone teach me how to read in a text file and place the numbers into an array? You don't have to give me a code unless you want. I am just looking for a general strategy to this since my array will have a different length each time I use a different text file.

And once I have my data into the array, it should be possible to do calculations onto the array, right. I.e, add 1.5 to all cells.

Thanks for helping me and have a nice day.

Is This A Good Question/Topic? 0
  • +

Replies To: Help with reading data from a .txt file into an array

#2 pdkharkar   User is offline

  • D.I.C Regular
  • member icon

Reputation: 65
  • View blog
  • Posts: 345
  • Joined: 19-January 09

Re: Help with reading data from a .txt file into an array

Posted 28 January 2010 - 04:17 PM

for inserting the elements into array
you have to first differentiate them
here is the logic for it

whenever you find there blank space between the two numbers then only the array should get the numbers
you can do this by file pointer
try for it
code it and then ask if anything goes wrong
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1