Question: CAN SOMEONE FIX MY ERROR? THIS IS MY CODE IOFUNCTIONS.C: int max_size; int readfile(struct pokemon pokearray[],int *num,char filename[]) { FILE *fptr; //file pointer //initialize the

CAN SOMEONE FIX MY ERROR?

CAN SOMEONE FIX MY ERROR? THIS IS MY CODE IOFUNCTIONS.C: int max_size;

THIS IS MY CODE IOFUNCTIONS.C:

int max_size; int readfile(struct pokemon pokearray[],int *num,char filename[]) { FILE *fptr; //file pointer //initialize the file pointer.. if it returns NULL then error must be there in reading file if ((fptr = fopen(filename, "r")) == NULL) { return 0; //unsuccessful reading of file // function returns 0 if pointer returns NULL. } int count =0;//denotes number of pokemons int data; /umber attached to each pokemon char name[50]; /ame of pokemon

//check if count is less than max size ..check whether file has reached end of line or not //if not EOF then data get the data stored with pokemon while(count

} int writefile(struct pokemon pokearray[],int num,char filename[]) { FILE *fptr; //delcare the file pointer //initialize the file pointer.. if it returns NULL then error must be there in writing file

if ((fptr = fopen(filename, "w")) == NULL) { return 0; // function returns 0 if file pointer returns NULL. } for(int i=0;i

}

int main() { printf("Enter the max size of array "); scanf("%d",&max_size);//take input of max size of array struct pokemon *pokearray =(struct pokemon*)(malloc)(sizeof(struct pokemon)*max_size);//allocate space int num=0;//intialize num variable printf("Enter the file to be read "); char filename[50]; scanf("%s",filename);//input the file name to be read

if(readfile(pokearray,&num,filename)==0) //call the readfile function { printf("Error in reading the file "); //error } else { printf("File read successfully %d pokemons has been stored in the array ",num); printf("Enter the name of the file on which data is to be written "); scanf("%s",filename);//input the file name of output file if(writefile(pokearray,num,filename)==0) { printf("Error in writing the file ");//error } else { printf("Data has been written successfully"); } }

}

In file included from iofunctions.c:23:0: iofunctions.h:19:30: error: array type has incomplete element type int readfile( struct pokemon pokearray[ ], int* num, char filename[ ] ); iofunctions.h:19:22: warning: 'struct pokemon' declared inside parameter list [enabled by default] int readfile( struct pokemon pokearray[ ], int* num, char filename[ ] ); iofunctions.h:19:22: warning: its scope is only this definition or declaration, which is probably not what you want [enabled by default] iofunctions.h:20:31: error: array type has incomplete element type int writefile( struct pokemon pokearray[ ], int num, char filename[ ] ); iofunctions.h:20:23: warning: 'struct pokemon' declared inside parameter list [enabled by default] int writefile( struct pokemon pokearray[ ], int num, char filename[]); iofunctions.c: In function 'readfile': iofunctions.c:52:4: error: ISO 690 forbids mixed declarations and code [-Wpedantic] int count =0;/*denotes number of pokemons*/ iofunctions.c:62:25: error: 'struct pokemon' has no member named 'data' pokearray(count-1].data=data; /*store the data in array*/ iofunctions.c: In function 'writefile': iofunctions.c:80:4: error: 'for' loop initial declarations are only allowed in 099 mode for (int i=0;i

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!