模拟实现strcat 的c语言程序

版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接: https://blog.csdn.net/A15029070725/article/details/84476301
#include<stdio.h>
#include<stdlib.h>
#include<assert.h>

void MyStrcat(char *str1, const char *str2){
    assert(str!=NULL);
    assert(str2!=NULL);
	while (*str1 != '\0'){
		str1++;
	}
	while (*str2 != '\0'){
		*str1 = *str2;
		str2++;
		str1++;
	}
	*str1 = '\0';
}

int main(){
	char str1[1024] = "abc";
	char str2[1024] = "dfsg";
	MyStrcat(str1, str2); 
	printf("%s\n", str1);
	system("pause");
	return 0;
}

猜你喜欢

转载自blog.csdn.net/A15029070725/article/details/84476301