很简单的C代码,执行时会报错:Abort trap: 6
void strcat2(char *s, char *t) {
//s指向'\0'
while(*s)
s++;
while(*s++ = *t++)
;
}
int main() {
char s[] = " hello ";
char t[] = " world ";
strcat2(s, t);
printf("%s\n", s);
printf("%s\n", t);
}
void strcat2(char *s, char *t) {
//s指向'\0'
while(*s)
s++;
while(*s++ = *t++)
;
}
int main() {
char s[] = " hello ";
char t[] = " world ";
strcat2(s, t);
printf("%s\n", s);
printf("%s\n", t);
}
