I'm trying to create a circular linked list from file. But the compiler shows an error in the lines
fgets(curr->FullN.LastN,Lmax,f);
curr->FullN.LastN[strlen(curr->FullN.LastN)-1]='\0';
The error:
cannot convert FILE* to char* for argument 1 to char *fgets(char*, int, FILE*)
Here the function:
Student *build_stack(char Name[]){
Student *tek,*stack,*curr;
tek = NULL; //At the beginning the list is empty
stack = tek;
FILE *f;
if(!(f = fopen(Name,"r")))
puts("Oops! file not found");
else{
while(!feof(f)){
curr = new Student;//memory allocation
if (stack == NULL)
stack = curr;
fgets(curr->FullN.LastN,Lmax,f);
curr->FullN.LastN[strlen(curr->FullN.LastN)-1]='\0'; CLR;
fgets(curr->FullN.FirstN,Lmax,f);
curr->FullN.FirstN[strlen(curr->FullN.FirstN)-1]='\0';
fgets(curr->FullN.SecondN,Lmax,f);
curr->FullN.SecondN[strlen(curr->FullN.SecondN)-1]='\0';
fgets(curr->Group,Lmax,f);
curr->Group[strlen(curr->Group)-1]='\0';
curr->APerformance.Mean = 0;
for(int i=0;i<5;i++){
CLR;
fscanf(f,"%f",&(curr->APerformance.B[i]));
curr->APerformance.Mean += curr->APerformance.B[i];
}
curr->APerformance.Mean /= 5.0;
curr->next = tek;
tek = curr;
}
}
if(stack){
stack->next = tek;
}
return stack;//pointer returns to the top of the stack
}