C++中的字符串类stirng①

#include <iostream>
#include <string>
using namespace std;
int main()
{
    string s_1;
    s_1 = "aaaaa";
    s_1.clear();
    char* c_1 = "bbbb";
    s_1.assign(c_1);
    
    s_1.append("aaaa");

    if (s_1.compare("bbbbaaaa") == 0)
    {
        cout << s_1 << endl;
    }
    else
    {
        cout << "not" << endl;
    }
    return 0;
}

 

posted on 2021-01-15 21:38  SakuraQAQ  阅读(53)  评论(0)    收藏  举报

导航