0

I have these a file in a c program which consist of a string and 4 doubles and 2 integer in one line and there is a total of 28 lines, i want to read this file and load the data into an array. can someone help me solve this.

3
  • 4
    Is this homework? Please show us what you have tried so far. Commented May 19, 2010 at 13:29
  • 1
    You don't have the "file in the C program". You might have the file, and need to write a C program to load the file and do something with the data in it, though. Your program will be a separate file. Commented May 19, 2010 at 13:31
  • Is the same data in the same place on each line? I.e. each line looks like this: string double double double double int int ? Additionally, do you want just one big array of doubles without context of what line they came from, or do you need to be able to relate doubles to strings, int's to doubles, etc? This question is almost ambiguous enough to be closed. Commented May 19, 2010 at 14:21

1 Answer 1

1

Split up your problem into sub-tasks:

  • Open the file using fopen
  • Allocate a buffer (array) to store the doubles
  • Create a loop while there is more to read
  • read in a single double into the array
  • Go to the next iteration
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.