一道细节纠错题
#include "stdio.h"void stringcat(char *s1,char *s2)
{
while(*(++s1)!='\0')
;
while(*s1++=*s2++)
;
}
int strlenth(char *string)
{
int i=0;
while(*string++!='\0')
i++;
return i;
}
int main(void)
{
char *p1="Welcome to china,";
char *p2="China is a great country";
stringcat(p1,p2);
printf("%s\n",p1);
printf("The lenth of p1 is %d\n",strlenth(p1));
printf("The lenth of p2 is %d",strlenth(p2));
return 0;
}
不知道上面的程序为什么运行出错,若改成p1[80],p2[40]则行,希望高人能相告