c8-18.c 434 B

1234567891011121314
  1. #include <stdio.h>
  2. int main()
  3. {char a[ ]="I am a student.",b[20];
  4. int i;
  5. for(i=0;*(a+i)!='\0';i++)
  6. *(b+i)=*(a+i); //将a[i]的值赋给b[i]
  7. *(b+i)='\0'; //在b数组的有效字符之后加'\n'
  8. printf("string a is:%s\n",a); //输出a数组中全部字符
  9. printf("string b is:");
  10. for(i=0;b[i]!='\0';i++)
  11. printf("%c",b[i]); //逐个输出b数组中全部字符
  12. printf("\n");
  13. return 0;
  14. }