using namespace std;
int main() {
char animal[20] = "bear";
const char* bird = "wren";
char* ps;
cout << animal << " and ";
cout << bird << "\n";
cout << "Enter a king of animal: ";
cin >> animal;
ps = animal;
cout << ps << "!\n";
cout << "Before using strcpy():\n";
cout << animal << " at " << (int*)animal << endl;
cout << ps << " at " << (int*)ps << endl;
ps = new char[strlen(animal) + 1];
strcpy(ps, animal);
cout << "After using strcpy():\n";
cout << animal << " at " << (int*)animal << endl;
cout << ps << " at " << (int*)ps << endl;
delete[] ps;
system("pause");
return 0;
}
strcpy,strlen,应用
原创
©著作权归作者所有:来自51CTO博客作者一叶孤舟渡的原创作品,请联系作者获取转载授权,否则将追究法律责任
上一篇:matlab之傻瓜式绘制各种图形
下一篇:matlab之图形修饰指令

提问和评论都可以,用心的回复会被更多人看到
评论
发布评论
相关文章
-
一维和二维数组sizeof和strlen的区别
sizeof和strlen的区别
bc 一维数组 二维数组 -
strcat strcpy strcmp strlen 的j简单实现
共享,不变的誓言!
C strcat strlen strcpy strcmp -
用指针编写strlen,strcat,strcpy等函数
用指针编写strlen,strcat,strcpy等函数
字符串 字符串比较 字符串函数 字符串连接 字符转换