在这里插入代码片#include<stdio.h>
#include<Windows.h>
#pragma warning(disable:4996)
#include<stdlib.h>
#include<assert.h>
char Mystrcpy(char* str, char* str1){
char* p = str;
char* pi = str1;
int len = strlen(str1);
assert(p != NULL);
assert(pi != NULL);
while (len){
*(p++) = *(pi++);
len--;
}
return *p;
}
int main()
{
char str[] = "hello";
printf("交换前str[]=%s \n", str);
char str1[] = "world";
Mystrcpy(str, str1);
printf("交换后str[]=%s\n", str);
system("pause");
return 0;
}
编写函数模拟strcpy函数功能
最新推荐文章于 2024-04-21 16:27:54 发布