Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C Programming > Reading into an array

Reply
Thread Tools

Reading into an array

 
 
djj858
Guest
Posts: n/a
 
      10-20-2003

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.


--
Posted via http://dbforums.com
 
Reply With Quote
 
 
 
 
Jirka Klaue
Guest
Posts: n/a
 
      10-20-2003
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

 
Reply With Quote
 
 
 
 
Jirka Klaue
Guest
Posts: n/a
 
      10-20-2003
I wrote:

> 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

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Reading SQL query into array Steve ASP .Net 1 08-30-2004 08:52 AM
Reading/writing data to/from files into 2D array Modukuri VHDL 0 05-19-2004 04:03 PM
Reading Blank Lines into StringTokens into Vector Array Row Java 0 04-14-2004 07:12 AM
reading from a file into an array Allen Seelye C++ 4 11-07-2003 07:49 PM
Reading a very large textfile into an array Markus Hofmann C++ 3 08-12-2003 04:59 PM



Advertisments