复制字符串
1 #include <iostream> 2 3 /* run this program using the console pauser or add your own getch, system("pause") or input loop */ 4 using namespace std; 5 int main(int argc, char** argv) { 6 char str1[]="I love CHINA!",str2[20],*p1,*p2; 7 p1=str1; 8 p2=str2; 9 for(;*p1!='\0';p1++,p2++) 10 *p2=*p1; 11 *p2='\0'; 12 p1=str1; 13 p2=str2; 14 cout<<"str1 is:"<<p1<<endl; 15 cout<<"str2 is:"<<p2<<endl; 16 return 0; 17 }