2
Guys look at this following code :
lista is a struct
lista * crialista()
{
lista *li;
li = (lista *) malloc(sizeof(struct lista));
if(li !=NULL)
{
li->qtd = 0 ;
}
}
because it was allocated lista in li with malloc ? whereas li was declared as lista , that no longer gives access to members of my struct lista?
lista *lidefines a pointer. But that pointer does not point anywhere defined! If you prefer a real object, you can dolista liwhich is a real object with uncirculated values; with a pointer you have to point it to a specific place (withmalloc()) and then assign values to the elements.– pmg