题目:
将字符串a复制为字符串b,然后输出字符串b,使用指针法完成
代码:
#include <stdio.h>
int main(){char a[]="I am love China!",b[20],*p1,*p2;p1 = a;p2 = b;for(;*p1!='\0';p1++,p2++){*p2 = *p1;}*p2 = '\0';printf("string a is:%s\n",a);printf("string b is:%s\n",b);return 0;
}
结果:
string a is:I am love China!
string b is:I am love China!Process returned 0 (0x0) execution time : 0.012 s
Press any key to continue.