pointers-memory · beginner · ~15 min

Fill an array

Write through an array pointer.

Challenge

Implement void fill(int *a, int n, int v) setting the first n elements to v.

Starter code

void fill(int *a, int n, int v) {
    /* TODO */
}

Solve this exercise in the browser editor — compile and run against the test harness, no setup required.