string

  • std::string length() and size() member functions.
    As per the documentation, these are just synonyms.

  • Error: invalid operands of types ‘const char [35]’ and ‘const char [2]’ to binary ‘operator+’

std::string str = "Hello " + "world"; // bad!
std::string str = std::string("Hello ") + "there " + "world"; // ok
const char *st = "hello";
// 赋值转换 
string st1 = st;
// 构造转换 
string s1(st, st + strlen(st));

// string转char *
string st = "My test";
//char *st1 = st;           // 错误类型不同 
//char *st1 = st.c_str();   // 错误类型不同, const char* c_str() const; st对象被析构时,其内容将丢失!
char *st1 = const_cast<char *>(st.c_str()) ;
上一篇:C#计算时间差


下一篇:干货|各种WAF绕过手法学习