阅读397 返回首页    go 阿里云 go 技术社区[云栖]


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

#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;
}

最后更新:2017-04-02 18:30:38

  上一篇:go 有关指针的数据类型
  下一篇:go ext-3.2的sdk下载地址