Data structures - List differences

2

Please let me know the real difference between these structures below:

typedef struct {
 int info;
 struct lista * prox
 struct lista * ant;
} tipo_lista;

and this:

struct noCliente {
 int tempoUtilizandoMesa;
 struct noCliente *ant;
 struct noCliente *prox;
};

typedef struct noCliente *CLIENTE;
    
asked by anonymous 01.06.2017 / 15:08

1 answer

2

In addition to member names, the first creates a new type that can be used anywhere in the code where a type fits, so tipo_lista becomes a type as much as int is a type.

In the second, create a structure called noCliente . This does not create a type, so if you want to instantiate it on an object you have to make it type struct noCliente , since the type is struct with a specialization.

Of course soon after this structure is used to create a type called CLIENTE which will always be a pointer, so it will be a type by reference that is not the default of structures. Using the pointer required the separation between the structure declaration and the type declaration.

    
01.06.2017 / 15:40