标签:演示 name ring 比较 void oid 操作 += pac
字符串string 可以进行相加操作, s.size(), s.length(),s.c_str() 转换为c语言类型
/* 字符串演示 */ #include <iostream> #include <cstring> using namespace std; int main(void) { string s = "hello"; s += " world"; cout << s << endl; string s2; s2 = s; cout << s << endl; //进行比较 string s3 = "hello world"; if (s == s3) { cout << "两个字符串内容相同" << endl; } cout << s.size() << endl; cout << s.length() << endl; cout << strlen(s.c_str()) << endl; }
标签:演示 name ring 比较 void oid 操作 += pac
原文地址:https://www.cnblogs.com/hyq-lst/p/12597198.html