I am looking to learn best practices for working with strings. Two issues that I have with strncat are that it is difficult to calculate how much space to allow, and that there may not be a null character in the string after the procedure.
So if I have two strings of unknown length, would this be the best way to concatenate them? Are there better ways?
strncat(str1, str2, sizeof(str1)-strlen(str2));
if( strlen(str1)==sizeof(str1) )
str1[sizeof(str1)-1]="\0";
Thanks!