Go4Expert (http://www.go4expert.com/)
-   C (http://www.go4expert.com/forums/c/)
-   -   unresolved external (http://www.go4expert.com/forums/unresolved-external-t19933/)

jhgan 31Oct2009 20:48

unresolved external
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 );

xpi0t0s 1Nov2009 15:55

Re: unresolved external
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 1Nov2009 19:12

Re: unresolved external
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 1Nov2009 20:04

Re: unresolved external
OOps, I think I made a mistake right from the start, I created the wrong project...sorry for all the trouble....

All times are GMT +5.5. The time now is 19:20.