2014年05月21日

来源:互联网 发布:淘宝猪哼少是正品澄清 编辑:程序博客网 时间:2024/04/27 22:31

practice 5-3: rewrite strcat(s,t) used pointer,copystring t to the end of string s

#include
void strcat1(char *s,char *t);
void strcpy1(char *s,char *t);
main()
{
 char s1[100]="hello";
 char s2[]="xmlee";
 strcat1(s1,s2);
 printf("%s",s1);
 return 0;
}
void strcat1(char *s,char *t)
{
 while(*s!='\0')
  s++;
 strcpy1(s,t);

}
void strcpy1(char *s,char *t)
{
 while(*s++=*t++);

}

 

CONCLUSION: it's so exciting to learn the pointerpart,it's my weak part,but i will conqur it anyway.

0 0
原创粉丝点击