unresolved external

jhgan's Avatar
Light Poster
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

#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");
                fscanf( fp, "%d", &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 shabbir; 1Nov2009 at 11:02.. Reason: Code blocks
xpi0t0s's Avatar, Join Date: Aug 2004
player[i].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?
jhgan's Avatar
Light Poster
The contents of data.txt are as follow:
PS:I have tried to remove the & but there is still fatal error

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
jhgan's Avatar
Light Poster
OOps, I think I made a mistake right from the start, I created the wrong project...sorry for all the trouble....