How can i access s[7] in s?
I didn\'t observe any difference between strncpy and memcpy. If I want to print the o
Others have pointed out your null-termination problems. You need to understand null-termination before you understand the difference between memcpy and strncpy.
The difference is that memcpy will copy all N characters you ask for, while strncpy will copy up to the first null terminator inclusive, or N characters, whichever is fewer. (If it copies less than N characters, it will pad the rest out with null characters.)