- /* 将字符串a复制到字符串b */
- # include <stdio.h>
- void main()
- {
- int i;
- char a[] = "I am a student.";
- char b[20];
- char *p1, *p2;
- p1 = a; p2 = b;
- for(; *p1!=' '; p1++, p2++)
- *p2 = *p1;
- *p2 = ' ';
- printf("string a is: %sn", a);
- printf("string b is: ");
- for(i=0; b[i]!=' '; i++)
- printf("%c", b[i]);
- printf("n");
- }