文章详情

  • 游戏榜单
  • 软件榜单
关闭导航
热搜榜
热门下载
热门标签
php爱好者> php文档>C++ string

C++ string

时间:2010-06-11  来源:cdy_0

std::string

std::string类模板提供了许多非常基本和重要的操作与支持,最基本可能就是内存自动管理了。
std::string会根据需要自动管理内存,用户无需再关心字符数组中的那个数组越界的问题。


#include <string>
#include <iostream>
#include <cstring> //使用C格式

int main()
{
  using namespace std;

  string s1("Hello!");//产生一个string类
  s1 += "Good morning";//追加
  s1 = s1 + s2;//合并

  string s3 = s1;//

  //查找子串
  if (npos != s1.find(s2)){
    cout<<"yes"<<endl;
  }

  int size = s1.size();
  //int size = strlen(s1.c_str());//C格式


  return 0;
}
相关阅读 更多 +
排行榜 更多 +
单挑幸存者安卓版

单挑幸存者安卓版

飞行射击 下载
决战战地指挥官

决战战地指挥官

飞行射击 下载
鸡仔幸存者最新版

鸡仔幸存者最新版

飞行射击 下载