网站制作在线版,中国科技成就新闻,佛山制作网站,网站如何做竞价点击上方蓝字关注我#xff0c;了解更多咨询1、dst 内存空间大小目标字符串长度原始字符串场地‘\0’。2、使用sizeof函数获取内存空间大小#xff0c;strlen函数获取字符串长度。即获取内存空间大小和查字符串长度。实例#include stdafx.h
#includestdlib.h… 点击上方蓝字关注我了解更多咨询1、dst 内存空间大小目标字符串长度原始字符串场地‘\0’。2、使用sizeof函数获取内存空间大小strlen函数获取字符串长度。即获取内存空间大小和查字符串长度。实例#include stdafx.h
#includestdlib.h
#includestdio.h
#includestring.h
#include windows.h//error C4996: strcat: This function or variable may be unsafe. Consider using strcat_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
#pragma warning( disable : 4996)void main()
{char src[1024] { C/C教程-strcat_s函数 };char dst[1024] { www.codersrc.com };//注意strcat_s第二个参数的计算该参数是拼接后的字符串大小并非原字符串大小或者目标字符串大小int len strlen(src) strlen(dst) 1;printf(strcat_s之前 dst:%s\n, dst); //strcat_s(dst, len, src);printf(strcat_s之后 dst:%s\n, dst);//system(pause);
}
输出结果
strcat_s之前 dst:www.codersrc.com
strcat_s之后 dst:www.codersrc.comC/C教程-strcat_s函数
请按任意键继续. . .END*声明本文于网络整理版权归原作者所有如来源信息有误或侵犯权益请联系我们删除或授权事宜。戳“阅读原文”我们一起进步