Reading into an array

Discussion in 'C Programming' started by djj858, Oct 20, 2003.

  1. djj858

    djj858 Guest

    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
     
    djj858, Oct 20, 2003
    #1
    1. Advertising

  2. djj858

    Jirka Klaue Guest

    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
     
    Jirka Klaue, Oct 20, 2003
    #2
    1. Advertising

  3. djj858

    Jirka Klaue Guest

    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
     
    Jirka Klaue, Oct 20, 2003
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Modukuri
    Replies:
    0
    Views:
    2,916
    Modukuri
    May 19, 2004
  2. Steve

    Reading SQL query into array

    Steve, Aug 30, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    537
    Hermit Dave
    Aug 30, 2004
  3. Row
    Replies:
    0
    Views:
    493
  4. Markus Hofmann
    Replies:
    3
    Views:
    739
    Jerry Coffin
    Aug 12, 2003
  5. Allen Seelye

    reading from a file into an array

    Allen Seelye, Nov 7, 2003, in forum: C++
    Replies:
    4
    Views:
    415
    Rolf Magnus
    Nov 7, 2003
Loading...

Share This Page