How to pass a pointer inside a struct per function parameter?

0

The situation is as follows:

I have a struct with a field that is a pointer pointer, however I want to pass as a parameter in a function only the pointer pointed to, that is, the most internal pointer of that field in the struct:

In code it would look like this:

typdef struct
{  
  int **ponteiro;
}Ponteiro;

I have the addressing assignment this way:

 grafo->vertices[posicao_B].vertice_adjacente[(grafo->vertices[posicao_B].qtd_adj‌​acentes-1)] = &grafo->vertices[posicao_A];  <-- aqui estou tentando fazer com que o ponteiro de ponteiro (**vertice_adjacente) aponte para o endereço  de  (&grafo->vertices[posicao_A])

And I'm trying to print like this, but nothing is being printed:

printf("Vertice adjacente de A %d\n",(grafo->vertices[posicao_A].vertice_adjacente[0]->num_vertice));

Just remembering that (vertex_adjacent) is an array of pointers dynamically allocated by a function that I have developed.

If you can help me, thank you!

    
asked by anonymous 25.10.2015 / 12:53

1 answer

0
typedef struct {int **ponteiro;} Ponteiro;

Ponteiro a;
int b;
int *c = &b;
a.ponteiro = &c;

fx(a.ponteiro);     // &c         : tipo int **
fx(*(a.ponteiro));  // &b         : tipo int *
fx(**(a.ponteiro)); // valor de b : tipo int
    
25.10.2015 / 13:21