Chinaunix首页 | 论坛 | 博客
  • 博客访问: 3413412
  • 博文数量: 534
  • 博客积分: 11595
  • 博客等级: 上将
  • 技术积分: 5785
  • 用 户 组: 普通用户
  • 注册时间: 2006-12-22 17:00
文章分类

全部博文(534)

文章存档

2015年(4)

2014年(27)

2013年(15)

2012年(38)

2011年(36)

2010年(85)

2009年(63)

2008年(142)

2007年(124)

分类: C/C++

2007-08-03 15:57:42

#include

函数1
copy_string(char from[],char to[])
{
 int i=0;
  while (from[i]!='\0') {
  to[i]=from[i]; i++;
  }
 to[i]='\0';
}

函数2
copy_string(char *from,char *to)
{
 for (;*from!='\0';from++,to++)
  *to=*from;
 *to='\0';
}

函数3
copy_string(char *from,char *to)
{
 while ((*to=*from)!='\0') {
   from++; to++;
 }
 *to='\0';
}

函数4
copy_string(char *from,char *to)
{
 while ((*to++=*from++)!='\0')
 *to='\0';
}

函数5
copy_string(char *from,char *to)
{
 while (*from!='\0')
   *to++=*from++;
 *to='\0'; 
}

函数6
copy_string(char *from,char *to)
{
 while (*from) //字符可用ascii代替,\0就是0,*from!=0 与 *from 为真实while执行
   *to++=*from++;
 *to='\0'; 
}

函数7
copy_string(char *from,char *to)
{
 for (;(*to++=*from++)!=0;)
 *to='\0'; 
}

函数8
copy_string(char *from,char *to)
{
 for (;*to++=*from++;)
 *to='\0'; 
}

函数8
copy_string(char from[],char to[])
{
 char *p1,*p2;
 p1=from;p2=to;
 while ((*p2++=*p1++)!='\0')
 *to='\0'; 
}

main()
{
 char a[]="i am a teacher.",b[]="i am a student.";
  printf("string_a=%s string_b=%s\n",a,b);

 copy_string(a,b);
 printf("string_a=%s string_b=%s\n",a,b);
}


阅读(1943) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~