为了账号安全,请及时绑定邮箱和手机立即绑定

自定义函数完成字符串的复制功能,并编写主函数来测试?

自定义函数完成字符串的复制功能,并编写主函数来测试?

C++
紫衣仙女 2019-02-05 15:07:03
自定义函数(函数为:char stringcpy(char*to,char*from))完成字符串的复制功能,并编写主函数来测试
查看完整描述

2 回答

?
动漫人物

TA贡献1815条经验 获得超10个赞

char *stringcpy(char *to,char *from)
{
int i = 0;
while(to[i] = from[i])
i++;
return to;
}

查看完整回答
反对 回复 2019-03-10
?
aluckdog

TA贡献1847条经验 获得超7个赞

#include "stdio.h"
char *stringcpy(char *to,char *from)
{
int i;
for(i=0;from[i];i++)
to[i]=from[i];
to[i]=0;
return to;
}
main()
{
char *s1="abc",*s2="abcdefg";
stringcpy(s1,s2);
puts(s1);
}


查看完整回答
反对 回复 2019-03-10
  • 2 回答
  • 0 关注
  • 761 浏览

添加回答

举报

0/150
提交
取消
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号