I was writing a code that creates a list with a sublist from a txt file. But for some reason, after opening the file and trying to read the first line, the watches show that they stay empty. The file "equipos.txt" is in the same folder, and I've checked the structures and they all seemed fine. I have a similar code in another project that works fine, but it doesn't seem to work here.
void crealista(tlista* l){
tlista nuevo,ant;
tsublista subnuevo,subant;
char vec[MAXnom];
FILE *arch;
arch=fopen("equipos.txt","rt");
if(arch=fopen("equipos.txt","rt")== NULL){
printf("Fallo al abrir archivo, puede no existir");
}
else{
(*l)=NULL;
ant=(*l);
while(feof(arch) == 0){
nuevo=(tlista)malloc(sizeof(nodo));
fscanf(arch,"%s %d",nuevo->equipo,&nuevo->puntaje);
nuevo->jugadores = NULL;
nuevo->sig = NULL;
fscanf(arch,"%s",vec);
subant=(nuevo->jugadores);
while(strcmp(vec,"ZZZ")!= 0){
subnuevo=(tsublista)malloc(sizeof(nodito));
strcpy(subnuevo->nombre,vec);
fscanf(arch,"%d %c",&subnuevo->edad,&subnuevo->estado);
subnuevo->sig = NULL;
if(nuevo->jugadores == NULL){
nuevo->jugadores = subnuevo;
}
else{
subant->sig = subnuevo;
subant = subnuevo;
}
fscanf(arch,"%s",vec);
}
if((*l) == NULL){
(*l) = nuevo;
}
else{
ant->sig = nuevo;
ant = nuevo;
}
}
}
fclose(arch);
}