自定义一个strcpy函数

来源:互联网 发布:hecras软件中堰流系数 编辑:程序博客网 时间:2024/05/20 18:20
#include<stdio.h>
#include<string.h>
#include<Windows.h>
#include<assert.h>
//自定义一个strcpy函数


char * my_strcpy(char* dest,const char* src )
{
assert(dest!=NULL);
assert(src!=NULL);
while(*src!='\0')
{
*dest = *src;
dest++;
src++;
}
*dest = *src;
}


int main()
{
char *p = "hello world";
char arr[20]={0};
my_strcpy(arr,p);
printf("%s\n",arr);
system("pause");


return 0;


}
原创粉丝点击