#include <iostream>
#include <assert.h>
using namespace std;
//串连字符串
char *strcat1(char *strDest, const char *strSrc)
{
assert(strDest != NULL && strSrc != NULL); //断言保证传进来的参数不是空
char *address = strDest;
while (*strDest != '\0')
{
++strDest;
}
while ( (*strDest++ = *strSrc++)!= '\0');
return address;
}
int main(void)
{
char s[20] = "hello world";//开辟多一点空间,不如塞不下t啊
char *t = "hello";
cout<<sizeof(s)<<endl;
cout<<strlen(s)<<endl;
cout<<strcat1(s,t)<<endl;
cout<<sizeof(s)<<endl;
cout<<strlen(s)<<endl;
system("pause");
return 0;
}串连字符串strcat
最新推荐文章于 2023-07-19 00:15:00 发布
4030

被折叠的 条评论
为什么被折叠?



