Logo

Programming-Idioms

This language bar is your friend. Select your favorite languages!

Idiom #284 Create a zeroed list of integers

Create a new list a (or array, or slice) of size n, where all elements are integers initialized with the value 0.

#include <stdlib.h>
int *a = calloc(n, sizeof(*a));

calloc automatically sets every byte allocated to 0.

New implementation...