C的一道题目---

来源:百度知道 编辑:UC知道 时间:2024/06/03 17:48:23
编一个程序,将字符数组S2中的全部字符拷贝到字符数组S1中,不用STRCPY函数.拷贝时,’\0’也要拷贝过去.’\0’后面的字符不拷贝.

int i=0;
do
{
s1[i]=s2[i];
i++
}while(s2[i]!='\0')

#include <stdio.h>
void main()
{
char *s1="Hello World!";
char s2[20];
char *src=s1,*dst=s2;
while(*dst++=*src++); //这一句就是复制,有问题hi我
printf("%s",s2);
}