pointers-memory · intermediate · ~15 min
Allocate exactly the combined size and copy both inputs.
Implement int *concat_arrays(const int *a, int na, const int *b, int nb) returning a new heap array of na+nb ints with a then b. The caller frees it.
#include <stdlib.h>
#include <string.h>
int *concat_arrays(const int *a, int na, const int *b, int nb) {
/* TODO */
return NULL;
}
Solve this exercise in the browser editor — compile and run against the test harness, no setup required.