malloc zeroing out memory?
c, malloc
Solution
`malloc` itself doesn't zero out memory but it many operating systems will zero the memory that your program requests for security reasons (to keep one process from accessing potentially sensitive information that was used by another process).
Problem
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 = 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?