Reading into an array

D

djj858

I am attempting to read in the contents of a file into a 2D array.



The file is laid out as follows:

XXXX X XX X XXXXX XXXXX

XXXX X XX X XXXXX XXXXX

...

...

...

for 15 rows.



Only the last 2 columns need to be read in to the program.



Since I have been learning C for about a week I have no idea
where to start.



Any help would be much appreciated.
 
J

Jirka Klaue

djj858 wrote:
....
I am attempting to read in the contents of a file into a 2D array.

The file is laid out as follows:

XXXX X XX X XXXXX XXXXX

Only the last 2 columns need to be read in to the program.

double x, y;
fscanf("%*s%*s%*s%*s%lf%lf ", &x, &y); /* assuming XXXXX are numbers */

Jirka
 
J

Jirka Klaue

I said:
fscanf("%*s%*s%*s%*s%lf%lf ", &x, &y); /* assuming XXXXX are numbers */

fscanf(f, "%*s%*s%*s%*s%lf%lf ", &x, &y);
^
File you've opened with fopen.

Jirka
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,022
Latest member
MaybelleMa

Latest Threads

Top