海口网站建设哪家专业,学做网站需要掌握哪些知识,什么平台可以推销自己的产品,wordpress 插件交互目录
学习strcat函数编辑
使用strcat函数编辑
模拟实现strcat函数 学习strcat函数
strcat函数所需要的头文件#xff1a; #includestring.h
strcat函数的参数解析#xff1a;
将 source 字符串追加到 destination 字符串。destination 中的字符串结束标志…目录
学习strcat函数编辑
使用strcat函数编辑
模拟实现strcat函数 学习strcat函数
strcat函数所需要的头文件 #includestring.h
strcat函数的参数解析
将 source 字符串追加到 destination 字符串。destination 中的字符串结束标志 \0 被 source 的第一个字符覆盖source 字符串后面的字符依次向后追加且 source 字符串的 \0 也要追加上
source 字符串的内容不会被改变所以可加上 const 关键字修饰
strcat函数的返回值
返回 destination 字符串的起始位置
注意
destination 字符串的空间要足够大能容纳下追加的 source 字符串否则就会报错 使用strcat函数 模拟实现strcat函数
char* my_strcat(char* destination, const char* source)
{// 断言assert(destination ! NULL);assert(source ! NULL);// 先保存目标字符串的首地址char* ret destination;// 找到目标字符串的\0while (*destination){destination;}// 追加while (*source){*destination *source;}// 返回目标字符串的首地址return ret;
}
代码验证