我有结构:
typedef struct Piloto {
int dorsal;
char inicialNombre[1];
char apellido1[50];
char nacionalidad[3];
int puntuacion;
struct Premio* premios[18];
int premioLibre;
} Piloto;
typedef struct Premio {
char nombre[50];
int puntos;
} Premio;
typedef struct Nodo {
struct Piloto piloto;
struct Nodo* siguiente;
} Nodo;
typedef struct Lista {
Nodo* cabeza;
int longitud;
} Lista;
typedef struct Equipo {
char nombre[50];
char marcaMoto[30];
int puntuaciones;
struct Piloto pilotos[18];
struct nodo* izquierdo;
struct nodo* derecho;
} Equipo;
typedef Equipo Arbol;
I mean,an Array premios
inside a linked list Piloto
inside a Binary Search Tree arbol
.
I'm trying check whether or not a premio
exists by name; for this I get a string passed per user and I iterate:
char gp[50];
char temp;
scanf("%c",&temp);
fgets(gp,50,stdin);
strtok(gp, "\n");
for (int i = 0; i < 18; i++) {
int comparado = strncmp(arbol->pilotos[0].premios[i]->nombre, gp, 50);
if (comparado == 0) {
printf("EXISTS");
}
}
But whenever I get to the line arbol->pilotos[0].premios[i]->nombre
throws: arbol->pilotos[0].premios[i]->nombre
.
为什么?而我该如何迭代此结构以进行检查呢?