编写程序来实现实现strcat()功能
strcat(字符数组1,字符串2)
字符串2的内容复制连接在字符数组1的后面,其返回值为字符数组1的地址
/* strcat(字符数组1,字符串2) 字符串2的内容复制连接在字符数组1的后面,其返回值为字符数组1的地址 编写函数实现strcat()功能 */ #define _CRT_SECURE_NO_WARNINGS #include<stdio.h> #include<stdlib.h> #include<string.h> void my_strcat(char str1[], char str2[]) { int nNum1, nNum2; nNum1 = strlen(str1); nNum2 = strlen(str2); for (int i = 0; i < nNum2; i++) { str1[nNum1 + i] = str2[i]; } } int main() { char strAry1[30] = "I like"; char strAry2[30] = "beijing"; my_strcat(strAry1, strAry2); puts(strAry1); strcat(strAry1, strAry2); puts(strAry1); my_strcat(strAry1, strAry2); puts(strAry1); system("pause"); return 0; }