0
Imagine a school with several classrooms, and each room has several students
I’m having trouble reading file with the name of the room, number of places by rows (rows and columns) I have the following structure!
typedef struct
{
char nome[50];
int numero;
}Aluno;
typedef struct nodo{
Aluno dados;
struct nodo *anterior;
struct nodo *seguinte;
}Nodo;
typedef struct{
char sala[50];
int linhas, colunas;
Nodo inicio;
} Lista;
And the next to read from the file, but I know it’s wrong
int LerFicheiro(char *nf)
{
FILE* w=fopen(nf, "r");
Lista* li;
int l,c;
while (!feof(w))
{
fread(&li->nome, sizeof(Lista), 1, w); // nome da sala
fread(&li->linhas, sizeof(Lista), 1, w); // nº linhas
fread(&li->colunas, sizeof(Lista), 1, w); // nº colunas
for (l = 0; l <= li->linhas; l++)
{
for (c = 0; c < li->colunas; c++)
{
/*LER NOMES E NUMEROS*/
}
}
}
fclose(w);
}
This is the file to read! It has the name of the room, in the following row the number of places in line and in column!!! Next is the student’s number and the name of the respective student
Sala de Historia
8 5
1231
Joao Afonso
563
Zé Alves
7634
Rita Pereira
948
Patricia Mendes
39
Rui Santos
Someone can make me or help me in this?
Thank you very much!!!!
Yes, my mistake, I’ve edited!!
– João Pereira
then you can still use what I sent you before, but replace the variables you had with the new ones (name, rows, columns)
– IanMoone
But, how will I do with the classrooms? my doubt is even this, read room by room the places with the students
– João Pereira
How have you been writing in the file? can you print out how the file is? so it’s easier to figure out how to help you
– IanMoone