std::string::assign函数

时间:2021-01-23 16:26:44
string& assign (const string& str);
string& assign (const string& str, size_t subpos, size_t sublen);
string& assign (const char* s);
string& assign (const char* s, size_t n);
string& assign (size_t n, char c); /*
std::string stra("helloworld");
std::string str;
str.assign(stra);
str.assign(stra,0,5);
*/ /*
char pch[15]="helloworld";
std::string str;
str.assign(pch);
str.assign(pch,5);
*/ /*
std::string str;
str.assign(5,'c');
*/