string

 string str = "sdfsdfsd1234fsdf";
    cout << str.size() << endl;
    cout << str.insert(str.size(), "123") << endl;
    cout << str.find("123") << endl;
    cout << str.substr(0, 4) << endl;
    cout << str.append("456") << endl;
    //resize 元素预留空间,并没有真正的创建,可以通过push insert 的方式添加
    str.reserve(50);
    cout << "size :" << str.size() << endl;
    // resize 则为实际扩充空间大小
    str.resize(50);
    cout << "size :" << str.size() << endl;
    string str1 = "我爱中国";
    cout << str1.size() << endl;
    cout << str1.length() << endl;
    // 当前机器最大string最大长度
    cout << str1.max_size() << endl;
原文地址:https://www.cnblogs.com/alplf123/p/8004339.html