zoukankan      html  css  js  c++  java
  • string::append

    string (1)
    string& append (const string& str);
    
    substring (2)
    string& append (const string& str, size_t subpos, size_t sublen);
    
    c-string (3)
    string& append (const char* s);
    
    buffer (4)
    string& append (const char* s, size_t n);
    
    fill (5)
    string& append (size_t n, char c);
    
    range (6)
    template <class InputIterator>
       string& append (InputIterator first, InputIterator last);
    
    initializer list(7)
    string& append (initializer_list<char> il);

    using namespace std;
    int main()
    {
    string s1 = "abc";
    string s2 = "def";
    s1.append(s2);
    cout << "1 " << s1 << endl;
    string s3 = "ghi";
    try{
    s1.append(s3, 4, 3);
    }catch(out_of_range){
    cout << "out_of_range" << endl;
    }
    cout << "2 " << s1 << endl;
    const char *s4 = "hello";
    s1.append(s4);
    cout << s1 << endl;
    const char *s5 = "weather";
    s1.append(s5, 3);
    cout << s1 << endl;
    s1.append(5, '$');
    cout << s1 << endl;
    string s6 = "12345";
    s1.append(s6.begin() + 1, s6.end() - 2);
    cout << s1 << endl;
    initializer_list<char> s7 = {'q', 'w', 'e', 'r'};
    s1.append(s7);
    cout << s1 << endl;
    return 0;
    }

  • 相关阅读:
    群资料共享
    python 智能合约日志操作
    canvas绘制图片
    rgb随机变色
    直接用css生成三角形的问题
    纯css三层侧边栏效果
    清除浮动终极版本
    懒加载
    html5可以通用的几段代码
    jquery中animate()动画方法
  • 原文地址:https://www.cnblogs.com/xpylovely/p/12082244.html
Copyright © 2011-2022 走看看