程序没问题啊,只要保证合并后的数组大小不超过20就行了
#include
void catstr( char *s1,char *s2 )
{
int i=0,j=0;
for( i=0;s1[i]!='\0';i++ );
do
{
s1[i++]=s2[j];
} while(s2[j++]!='\0');
}
int main()
{
char s1[100],s2[100];
printf("input s1: " ); gets(s1);
printf("input s2: " ); gets(s2);
catstr( s1,s2 );
printf("s1=%s\n", s1 );
return 0;
}
#include
void func(char *a,char *b)
{
for(;*a;a++);
for(;*a++=*b++;);
}
int main(void)
{
char a[100]="12345",b[]="67890";
func(a,b);
puts(a);
return 0;
}