basics · beginner · ~15 min
Copy bytes until and including the NUL.
Copy one C string into a destination buffer, terminator included.
Implement void str_copy(char *dst, const char *src) that copies the string src into dst, including the terminating NUL byte. dst is guaranteed large enough. No main — the grader calls it.
A destination buffer dst (big enough), and a NUL-terminated source string src.
No return value. After the call, dst holds a copy of src.
str_copy(dst, "hello") -> dst == "hello"
str_copy(dst, "") -> dst == ""
str_copy(dst, "abc") -> dst == "abc"
'\0' too, or dst won't be a valid string.A destination buffer dst (large enough), and a NUL-terminated source src.
No return value; dst is filled with a copy of src.
dst is large enough; copy the terminating NUL.
void str_copy(char *dst, const char *src) {
/* TODO */
}
Solve this exercise in the browser editor — compile and run against the test harness, no setup required.