It's the OS linker/loader that zeros the pages used by a new process to avoid leaking memory contents of previous processes (security risk).
It's zero only because this occurs at the very beginning of the program. In general it would be undefined.
It's zero only because this occurs at the very beginning of the program. In general it would be undefined.
This is easily testable.
#include <stdio.h>
int main(void) {
char* pointers[20];
int i;
for (i = 0; i < 20; ++i) {
printf("%p\n", pointers[i]);
}
return 0;
}
And yes when I run it, most of the pointers are not null.It just happened to be zero in the author's case.