Given this C code compiled with gcc 4.3.3
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char * argv[])
{
int * i;
i = (int *) malloc(sizeof(int));
printf("%d\n", *i);
return 0;
}
I would expect the output to be whatever was in the memory that malloc() returns, but instead the output is 0. Is malloc zeroing out the memory it returns? If so, why?