一级a做爰片免费网站性恔千锋教育的口碑怎么样
目录
学习strcat函数编辑
使用strcat函数编辑
模拟实现strcat函数
学习strcat函数
strcat函数所需要的头文件:
#include<string.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;// 找到目标字符串的'\0'while (*destination){destination++;}// 追加while (*source){*destination++ = *source++;}// 返回目标字符串的首地址return ret;
}
代码验证: