Warning! The behavior of strncpy() on overlapping strings is undefined. Many implementations of strncpy() use a "block move" machine instruction, which may or may not work the way you expect when the source and destination overlap.