Thought I would post this here as it is the forum closest to this topic that I could find.
I'm trying to write this program for class, and I'm having trouble doing part of it.
What it needs to do is read a file and put the data into arrays. The file has 4 lines, with double variables on each line, separated by spaces (2 spaces for some reason). Each line needs to be entered into a separate array, so that there are 7 numbers in the first array, 7 in the second, 3 in the 3rd, and 3 in the fourth. He says we are supposed to use fscanf in order to read in the data, but I thought I read that it did not work with spaces. We are using loops to enter each variable, so there will be 4 loops total, 1 for each array/line.
The text file looks like:
xxxx xxxx xxxx xxx xxx xxxx xxxx
xxxx xxx xxxx xxx xxx xxxx xxxx
xxx xx xxx
xxxx xx xxxx
With the x's being numbers.
It has to be using C, no C++ commands.
THanks for any help in advance.
I'm trying to write this program for class, and I'm having trouble doing part of it.
What it needs to do is read a file and put the data into arrays. The file has 4 lines, with double variables on each line, separated by spaces (2 spaces for some reason). Each line needs to be entered into a separate array, so that there are 7 numbers in the first array, 7 in the second, 3 in the 3rd, and 3 in the fourth. He says we are supposed to use fscanf in order to read in the data, but I thought I read that it did not work with spaces. We are using loops to enter each variable, so there will be 4 loops total, 1 for each array/line.
The text file looks like:
xxxx xxxx xxxx xxx xxx xxxx xxxx
xxxx xxx xxxx xxx xxx xxxx xxxx
xxx xx xxx
xxxx xx xxxx
With the x's being numbers.
It has to be using C, no C++ commands.
THanks for any help in advance.