Hi, i've a problem with fget, cause when i try to open the file i get Segmentation Fault...Anyone knows whats wrong?
Code:
void fgetrestaurante(List Mainlist) {
List random=cria_lista(random);
List Last=cria_lista(Last);
Last=(List)malloc(sizeof(List_node));
int cnt=-1;
Restaurante rest;
random=Mainlist->next;
FILE *fp = fopen("data.dat", "rb");
if (fp != NULL){
while(!feof(fp)){
cnt=fread(&rest, sizeof(Restaurante), 1, fp);
if (cnt){
random->info=rest;
random->next=(List) malloc (sizeof (List_node));
Last=random;
random=random->next;
}else
Last->next=NULL;
}
}
fclose(fp);
}