您的位置:首页 > 其它

不调用字符串库函数,实现字符串复制函数

2013-10-21 10:05 288 查看
#include<stdio.h>
#include<stdlib.h>
#include<assert.h>

void stringcpy(char *to,const char *from)
{
assert(to != NULL && from != NULL);
while(*from != '\0')
*to++ = *from++;
*to = '\0';
}
int main()
{
char *f;
char *t;
f = (char *)malloc(15);
t = (char *)malloc(15);
stringcpy(f,"123456");
stringcpy(t,f);
printf("t=%s\n",t);
return 0;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐