高仿模拟练习,补全 found 标记处空缺,答案点击按钮展开
自定义my_strcpy函数,把s2字符串复制到s1,禁止调用库strcpy,请补全程序。
#include <stdio.h>
void my_strcpy(char *s1,char *s2)
{
while(*s2 != '\0')
{
/**********found**********/
*s1 = ___1___;
/**********found**********/
___2___;
/**********found**********/
s1++;
}
*s1 = '\0';
}
int main()
{
char str1[100],str2[100];
gets(str2);
my_strcpy(str1,str2);
printf("%s\n",str1);
return 0;
}
*s2
s2++
第1空把源字符串字符赋值给目标字符串;第2空源指针向后移动;第3空目标指针向后移动。输入test,复制后输出test。