1
typedef struct vertice
{
int num_vertice;
int profundidade;
struct vertice **vertices_adja;
} Vertice;
typedef struct grafo
{
int qtd_vertices;
int *Vertice;
} Grafo;
I want to access the attributes of struct 'Vertice' inside the graph, the way I’m trying to do it is this.
Grafo* criarGrafo(int *vertices, int qtd_vertices)
{
Grafo *grafo_A;
grafo_A = malloc(sizeof(Grafo));
grafo_A->Vertice = alocarVertices(qtd_vertices);
if(grafo_A->Vertice != NULL)
{
grafo_A->qtd_vertices = qtd_vertices;
int i = 0 ;
for( ; i < qtd_vertices; i++)
{
(grafo_A)->Vertice[i]->num_vertice = vertices[i]; <-- Aqui está erro "error: invalid type argument of ‘->’ (have ‘int’)"
}
return grafo_A;
}
}
Just one more question, the struct ' Vertice' inside the graph is a pointer, so I wouldn’t have to reference it with the operator "->", so: graph_A->Vertice[i]->num_vertice; why this isn’t correct?
– Nayron Morais
Vertice
is a type pointerstruct vertice *
;Vertice[i]
is a type objectstruct vertice
.– pmg