An assignment cycle is a bad idea because you are reinventing the wheel. You can make a mistake, and your code is likely to be less efficient than the code in the standard library (some processors have optimized instructions for copies of memory, and optimized implementations usually at least copy word by word, if possible).
However, note that strncpy not a well-rounded wheel. In particular, if the string is too long, it does not add a null byte to the destination. The BSD strlcpy function is better developed, but not available everywhere. Even strlcpy not a panacea : you need to get the buffer size correctly and know that it can trim the string.
A portable way to copy a truncated string if the string is too long is to call strncpy and always add a terminating null byte. If the buffer is an array:
char buffer[BUFFER_SIZE]; strncpy(buffer, source, sizeof(buffer)-1); buf[sizeof(buffer)-1] = 0;
If the buffer is specified by pointer and size:
strncpy(buf, source, buffer_size-1); buf[buffer_size-1] = 0;
source share