Why does malloc
always initialize with garbage values and calloc
always intialize with 0? Any reason behind it?
Why can't we use realloc
instead of malloc
for dynamic memory allocation?
After reallocating memory dynamically, what are initial values of it?
Code:
int *ptr;
ptr = (int *) realloc(ptr,50);
printf("%d",*ptr);