Here is the code I\'m using:
#include
#include
int main() {
int *arr;
int sz = 100000;
arr = (int *)malloc(sz *
void *malloc(size_t size) is just supposed to keep aside the specified amount of space. That's all. There is no guarantee as to what will be present in that space.
Quoted from the man pages:
The
malloc()function allocates size bytes and returns a pointer to the allocated memory. The memory is not initialized. Ifsizeis 0, thenmalloc()returns either NULL, or a unique pointer value that can later be successfully passed tofree().
Apart from calloc() you can use the memset() function to zero out a block of memory.