用函数调用实现字符串的复制

来源:互联网 发布:js分享微信朋友圈demo 编辑:程序博客网 时间:2024/06/06 01:53
#include<stdio.h>
int main()
{
void copy_string(char from[],char to[]);
char a[]="I am a student";
char b[]="You are a student";
printf("string a=%s\nstring b=%s\n",a,b);
printf("copy string a to string b:\n");
copy_string(a,b);
printf("\nstring a=%s\nstring b=%s\n",a,b);
return 0;
}
void copy_string(char from[],char to[])
{
int i=0;
while(from[i]!='\0')
{
to[i]=from[i];
i++;
}
to[i]='\0';
}
0 0