Hello,
I'm using malloc several times in the same pointer, such as:
int i;
my_structure_t* my_structure
while(true)
{
my_structure = malloc(sizeof(m y_structure_t)) ;
printf("%d\n", my_structure);
}
But I'm finding out that, no matter how many times I call malloc in
the pointer, every time my pointer points to the same memory position.
Is this correct or am I speaking nonsense here? If I'm correct, how
can I do to allocate new memory on each call?
I'm using gcc on linux.
Regards,
André
I'm using malloc several times in the same pointer, such as:
int i;
my_structure_t* my_structure
while(true)
{
my_structure = malloc(sizeof(m y_structure_t)) ;
printf("%d\n", my_structure);
}
But I'm finding out that, no matter how many times I call malloc in
the pointer, every time my pointer points to the same memory position.
Is this correct or am I speaking nonsense here? If I'm correct, how
can I do to allocate new memory on each call?
I'm using gcc on linux.
Regards,
André
Comment