I can see many sprintf's used in my applications for copying a string. I have a character array: char myarray[10]; const char *str = "mystring"; Now if I want want to copy the string str into myarray, is is better to use: sprintf(myarray, "%s", str); or strncpy(myarray, str, 8); ?