#include <iostream>
#include <string>
#include <cstring>
using namespace std; int main()
{
{
string s = "tom and jerry";
const char* c_s = s.c_str();
cout << "---------------" << endl;
cout << c_s << endl;
cout << s << endl;
} {
const char* c_s = "tom and jerry";
string s(c_s);
cout << "---------------" << endl;
cout << c_s << endl;
cout << s << endl;
} {
string s = "tom and jerry";
char* c;
const int len = s.length();
c = new char[len+];
strcpy(c, s.c_str()); //#include <cstring>
cout << "---------------" << endl;
cout << c << endl;
cout << s << endl;
} {
char* c = "tom and jerry";
string s(c);
cout << "---------------" << endl;
cout << c << endl;
cout << s << endl;
} {
const char* c = "tom and jerry";
char* pc = new char[];
strcpy(pc, c);
cout << "---------------" << endl;
cout << c << endl;
cout << pc << endl;
} return ;
}

最新文章

  1. 那些年【深入.NET平台和C#编程】
  2. python集成开发工具
  3. C#使用 UdpClient 类进行简单通信的例子
  4. Android.mk学习 笔记
  5. JSP中的EL
  6. uvalive 7331 Hovering Hornet 半平面交+概率期望
  7. 【BZOJ1042】【DP + 容斥】[HAOI2008]硬币购物
  8. c#判断输入textbox是否为数字
  9. table行转列
  10. Selenium之偷懒教程
  11. cocos2dx 制作单机麻将(一)
  12. 通过EA导入数据库存在表结构并生成文档
  13. XAMPP命令之LAMPP
  14. 转 ORACLE数据库它可以存储 中文 字节或字符
  15. 《玩转Bootstrap(基础)》笔记
  16. JS中OOP之模拟封装和继承和this指向详解
  17. PHPstorm 函数时间注释的修改
  18. 同步socket处理
  19. linux 系统 网卡 ethX没有显示IP的处理方式
  20. GCD LCM UVA - 11388 (思维。。水题)

热门文章

  1. 关于System.Collections空间
  2. Emmet 语法大全(缩写语法/sublime 插件)
  3. 关于Could not parse configuration: /hibernate.cfg.xml的问题
  4. (Android)View.getHeight或getWidth为0时的一些解决方案
  5. win7下的mstsc ubuntu下的rdesktop
  6. 将svn添加到系统服务
  7. mysql数据库分组(GROUP BY)查询实例
  8. Linux小白最佳实践:《超容易的Linux系统管理入门书》(连载五)Linux系统的对话方式
  9. 使用Script元素发送JSONP请求
  10. cplusplus解析