pointers-memory · intermediate · ~15 min
Use calloc for zeroed memory.
Implement int *zeros(int n) returning an array of n ints allocated with calloc (so every element is 0). The caller frees it.
#include <stdlib.h>
int *zeros(int n) {
/* TODO */
return NULL;
}
Solve this exercise in the browser editor — compile and run against the test harness, no setup required.