Array help

This is a discussion on Array help within the C Programming forums, part of the General Programming Boards category; i am still having some problems with getting my arrays filled. I have to read a file and make an ...

  1. #1
    Registered User
    Join Date
    Nov 2001
    Posts
    10

    Array help

    i am still having some problems with getting my arrays filled.

    I have to read a file and make an array for STD #'s and then one that has their test scores.

    In the File the data looks like..

    STD # T1 T2 T3 T4 T5
    1234 45 45 45 55 56
    5465 78 87 78 87 87

    I can get the STD numbers alone, but I can't get the test scores without it including the STD # also. Please help...

    Ryan

  2. #2
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,452
    Code:
    int s, i;
    int student_id[40];
    int student_scores[40][5];
    for ( s = 0 ; s < 40 ; s++ ) {
        fscanf( fp, "%d", &student_id[s] );
        for ( i = 0 ; i < 5 ; i++ ) {
            fscanf( fp, "%d", &student_scores[s][i] );
        }
    }
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 16
    Last Post: 05-29-2009, 07:25 PM
  2. Replies: 6
    Last Post: 11-09-2006, 02:28 AM
  3. [question]Analyzing data in a two-dimensional array
    By burbose in forum C Programming
    Replies: 2
    Last Post: 06-13-2005, 07:31 AM
  4. Unknown Memory Leak in Init() Function
    By CodeHacker in forum Windows Programming
    Replies: 3
    Last Post: 07-09-2004, 09:54 AM
  5. Quick question about SIGSEGV
    By Cikotic in forum C Programming
    Replies: 30
    Last Post: 07-01-2004, 07:48 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21