I want to copy a string into a char array, and not overrun the buffer.
So if I have a char array of size 5, then I want to copy a maximum of 5 bytes from a string in
Some nice libc versions provide non-standard but great replacement for strcpy(3)/strncpy(3) - strlcpy(3).
strcpy(3)
strncpy(3)
If yours doesn't, the source code is freely available here from the OpenBSD repository.