Does strcat()
return an error as strcat_s()
does? Can strcat()
replace strcat_s()`?
char str1[50] = "To be, or not to be, ";
char str2[] = "that is the question.";
int retval = strcat_s(str1, sizeof str1, str2);
if(retval)
printf("There was an error joining the strings. Error code = %d",retval);
else
printf("The combined strings:\n%s\n", str1);
strcat()
does not return an error code but you can still use it incorrectly and run into errors. It can be used instead ofstrcat_s()
likeIt may help you to look up a reference for C functions like cppreference.com/w/c to find out the answer to similar questions like this.