您的位置:首页 > 编程语言 > C语言/C++

C++实现用指针复制字符串

2012-04-16 16:40 411 查看
#include <iostream>
using namespace std;
int main() {
	char str1[] = "I love CHINA!",str2[20],*p1,*p2;
	p1 = str1;
	p2 = str2;
	char *p4="Wo ye Cuo";
	while(*p1!='\0'){
		*p2++=*p1++;
	}
	*p2='\0';
	p1=str1;
	cout<<str2<<endl;
	p2=str2;
	cout << "str1 is: "<<p1<<endl;
	cout << "str2 is: "<<p2<<endl;
	return 0;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: