【发布时间】:2015-08-12 15:01:28
【问题描述】:
strcat() 是否像 strcat_s() 一样返回错误? strcat()可以替换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() 的手册页并将其与 strcat_s() 的手册页进行比较。手册页对返回值提供了非常丰富的信息。 strcat 的“google”会发现大量关于 strcat() 的限制和使用 strncat() 的偏好的参考资料。
-
感谢参考。