I know there is a problem in realloc but I don't know why
Code:
#include <stdio.h>
#include <stdlib.h>
struct mystruct
{
int valore;
struct mystruct *next;
};
typedef struct mystruct Struct;
void crea_lista(Struct *mystruct, int *dim);
void modifica_lista();
void elimina_lista();
void aggiugni_lista();
int main()
{
int i,dim=0;
Struct *strutture;
for(i=0;i<2;i++)
crea_lista(strutture,&dim);
return 0;
}
void crea_lista(Struct *mystruct, int *dim)
{
int newdim=*dim+1;
printf("%d - ",newdim);
if(newdim==1)
mystruct=malloc(newdim*sizeof(Struct));
else
mystruct=realloc(mystruct,newdim*sizeof(Struct));
*dim=newdim;
printf("%d\n",sizeof(mystruct));
}