/*字符串的拼接,将s2拼接到搜s1的后边*/
# include <stdio.h>
int main ()
{ char s1[1024] = " " ;
char s2[1024] = " " ;
printf ("pleade input strings for s1\n s1 = ") ;
scanf ("%s",s1);
printf ("pleade input strings for s2\n s2 = ") ;
scanf ("%s",s2);
printf ("s1=%s\n",s1);
printf ("s2=%s\n",s2);
int len1 , len2 ;
int i , j ;
for (i=0 ; s1[i] ; i++);
len1 = i ;
#ifdef DEBUG
printf ("len1=%d\n",len1);
#endif
for (j=0 ; s2[j]; j++);
len2 = j ;
#ifdef DEBUG
printf ("len2=%d\n",len2);
#endif
j = len1+len2 ;//j是新字符串的长度
#ifdef DEBUG
printf ("j=%d\n",j) ;
#endif
for (;i>=0;j--,i--) //从后向前复制,将s1复制到s1全新的位置,长度不变
s1[j] = s1[i] ;
for (j=0 ;s2[j] ; j++)
s1[j]=s2[j] ;//将s1复制到s1新位置之后,新的字符串前边是空置的,将s2复制过去
printf ("\nafter joint \n\n");
printf ("s1=%s\n",s1) ;
printf ("s2=%s\n",s2) ;
return 0 ;
}