1 #include <stdio.h> 2 /* 3 题目:练习字符串链接 4 */ 5 int main(void) 6 { 7 char name1[30] = "abc"; 8 char name2[30] = "defdasdasd"; 9 10 char *p1,*p2; 11 p1 = name1; 12 p2 = name2; 13 14 while(*p1)//将指针指向字符串末尾 15 p1++; 16 while(*p2)//从p1的' '处开始追加字符,最后连同p2的' '也追加给p1. 17 *p1++ = *p2++; 18 printf("%s ",name1); 19 20 return 0; 21 }