Save and access data from structures within structures

Asked

Viewed 37 times

0

Good evening! I am learning to program in c and I have a problem, someone can help me?

typedef struct utente //Armazena o nome, número de utente, data de nascimento de um utente, assim como se se trata de um utente de rsico ou não
{

    int num;
    char nome[27];
    char nascimento[11];
    char risco;

} utente_tipo;

typedef struct concelho //Armazena o nome, código e número de habitantes de um concelho
{
    char nome[30];
    int code;
    int habitantes;

} concelho_tipo;

typedef struct rastreio
{
    utente_tipo utente;
    concelho_tipo concelho;
    char data[11];
    char teste;
    char sintomas[40];
} rastreio_tipo;

How should I store and access data from the tracking structure?

  • I don’t know if I understood your doubt, it would be something like rastreio_tipo.utente.num or rastreio_tipo.concelho.habitantes?

  • Exactly, my doubt is exactly how I articulate the three structures, that is, how to access the data inhabitants, risk and so of the user structure_type and concelho_type through trace_type

  • So I understand each instance of rastreio_tipo should have multiple concelhos and utentes associated, but its statement only associates one concelho and a utente to rastreio_tipo.

  • Can you explain it better please? I don’t understand why it has to be like this...

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.