1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

unresolved external

Discussion in 'C' started by jhgan, Oct 31, 2009.

  1. jhgan

    jhgan New Member

    Joined:
    Oct 31, 2009
    Messages:
    5
    Likes Received:
    0
    Trophy Points:
    0
    Hi, anyone knows why my code is giving me a 'fatal error'?
    I have already put my data file data.txt in the correct directory so it should not be the
    problem....:undecided



    Code:
    #include <stdio.h>
    #include <string.h>
    #include <ctype.h>
    #include <stdlib.h>
    
    struct type_player
    {
            char name1[20], name2[20];
            int scoring_ability1, scoring_ability2, valid;
    };
    
    // function prototypes 
    void read( struct type_player player[], int *N );
    
    
    int main()
    {
            struct type_player player[100];
            int N;
    
            read( player, &N );
            //check( player, N );
            //best( player, N);
    
            return 0;
    }
    //implement function 'read'
    void read( struct type_player player[], int *N )
    {
            int number=0, i;
            FILE *fp = fopen( "data.txt", "r" );
            if( fp==NULL )
                    printf( "Unable to open the file");
            else
            {
                    fscanf( fp, "%d", &number);
                    *N=number;
                    for( i=0; i<number; i++ )
                    {
                            fscanf( fp, "%s %s %d %d", &player[i].name1, &player[i].name2, &player[i].scoring_ability1, &player[i].scoring_ability2 );
                    }
            }
            fclose( fp );
    }
     
    Last edited by a moderator: Nov 1, 2009
  2. xpi0t0s

    xpi0t0s Mentor

    Joined:
    Aug 6, 2004
    Messages:
    3,012
    Likes Received:
    203
    Trophy Points:
    0
    Occupation:
    Senior Support Engineer
    Location:
    England
    player.name1 is already the address of where you want the data to go, so you don't need to take its address again.
    If that doesn't fix it, what are the contents of data.txt?
     
  3. jhgan

    jhgan New Member

    Joined:
    Oct 31, 2009
    Messages:
    5
    Likes Received:
    0
    Trophy Points:
    0
    The contents of data.txt are as follow:
    PS:I have tried to remove the & but there is still fatal error

    7
    pele polo 93 94
    maradona maradoni 93 94
    vanbasten vanboston 92 93
    shearer shaeror 91 93
    gullit glulit 89 94
    shevchenko shevchinko 80 75
    cronaldo crinaldo 90 99
     
  4. jhgan

    jhgan New Member

    Joined:
    Oct 31, 2009
    Messages:
    5
    Likes Received:
    0
    Trophy Points:
    0
    OOps, I think I made a mistake right from the start, I created the wrong project...sorry for all the trouble....
     

Share This Page