Chinaunix首页 | 论坛 | 博客
  • 博客访问: 196219
  • 博文数量: 51
  • 博客积分: 1435
  • 博客等级: 上尉
  • 技术积分: 590
  • 用 户 组: 普通用户
  • 注册时间: 2011-03-05 18:33
文章分类

全部博文(51)

文章存档

2012年(17)

2011年(34)

分类: C/C++

2011-04-15 13:05:50

  1. #include <stdio.h>
  2. #include <assert.h>
  3. #include <malloc.h>
  4. char *strcy(char *,const char*);

  5. /*enum Color{
  6.     GREEN = 1,
  7.     RED,
  8.     BLUE,
  9.     GREEN_RED = 10,
  10.     GREEN_BLUE
  11. }CorlorVal;
  12. */
  13. int main(void)
  14. {
  15.     /*char *p;
  16.     char *t;
  17.     p=(char *)malloc(15*sizeof(char));
  18.     t=(char *)malloc(15*sizeof(char));
  19.     strcy(p,"abcdef");
  20.     strcy(t,p);
  21.     printf("%s %s\n",p,t); */
  22.     char b[]="123";
  23.     char a[]="123456789";
  24.     
  25.     strcy(b,a);
  26.     printf("%s %s\n",a,b);
  27.     //printf("%d\n",sizeof(CorlorVal));
  28.     //printf("%d\n",sizeof(long));
  29.     return 0;
  30. }
  31. char*strcy(char *des,const char*src)
  32. {    
  33.     assert((des!=NULL) && (src!=NULL));
  34.     while(*src!='\0')
  35.     {
  36.         *des++=*src++;
  37.     }
  38.     *des='\0';
  39.     return des;

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