pointers-memory · intermediate · ~15 min
Bound a copy by the destination capacity.
Implement int safe_copy_n(int *dst, int dstcap, const int *src, int n) copying at most min(n, dstcap) ints into dst and returning the number actually copied — never overrunning dst.
int safe_copy_n(int *dst, int dstcap, const int *src, int n) {
/* TODO */
return 0;
}
Solve this exercise in the browser editor — compile and run against the test harness, no setup required.