M
Martin Andert
Hello,
I have a question regarding malloc and free.
Here my code sample:
int main()
{
/* allocating dynamic memory for array */
int* array = (int*) malloc(5 * sizeof(int));
/* ... program code ... */
array = (int*) malloc(4 * sieof(int));
free(array);
}
Now my question: The second time I allocate
memory for array, what happens to the
address that I got with the first malloc?
Is it freed automatically?
Martin
I have a question regarding malloc and free.
Here my code sample:
int main()
{
/* allocating dynamic memory for array */
int* array = (int*) malloc(5 * sizeof(int));
/* ... program code ... */
array = (int*) malloc(4 * sieof(int));
free(array);
}
Now my question: The second time I allocate
memory for array, what happens to the
address that I got with the first malloc?
Is it freed automatically?
Martin