Problems accessing struct members [closed]

0

I have to do some functions with these structs, but since Agenda has a vector of structs Contact and in each contact has another struct Data, how do I access the fields? Do I have to work each struct separately? Thanks in advance, follow the code.

typedef struct Data{
    int dia,mes,ano;
}t_data;

typedef struct Contato{
    char nome[40];
    char fone[12];
    int idade;
    t_data dataNascimento;
}t_contato;

typedef struct Agenda{
    t_contato contatos[200];
}t_agenda;
    
asked by anonymous 26.11.2018 / 18:47

1 answer

0

Assuming that you declared a t_agenda as the one written below, to access an element of the contatos vector, you should do the following:

//declaração da variavel
t_agenda agenda;
//acessa o dia do t_data, onde 'indice' deve ser substituido pelo valor do indice
agenda.contatos[indice].dataNascimento.dia;
    
26.11.2018 / 19:46