std::string

来源:互联网 发布:网络交换机使用方法 编辑:程序博客网 时间:2024/04/29 21:04

使用 std:: string 要#include<string>

1 构造函数

     std::string  tmp_str((char*)dSipAOR);  字符串dSipAOR为参数构造string tmp_str

2  查找函数 

    tmp_str.find('@',0);  //从tmp_str第0个字符开始查找,出现字符@的位置 //返回值从0开始

    如果找不到,返回std::string::npos。 他是这样定义的:static const size_type npos = -1;

3  获取字串

    user_name = tmp_str.substr(0,loc); 获取从0开始的loc个字符组成新的字符串

4 字符串清空

   domain_name.erase(); 



0 0