C++-字符串(string) 布尔类型(bool)
字符串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; }
布尔类型 bool,真表示1,假表示0
/* bool类型 */ #include <iostream> using namespace std; int main(void) { bool b = false; cout << boolalpha << b << endl; //使得打印出来的数据是bool类型 boolalpha cout << sizeof(b) << endl; b = 3 + 5; cout << "b=" << b << endl; b = 1.2 * 3.4; cout << "b=" << b << endl; char* p = NULL; b = p; cout << "b=" << b << endl; //地址是空的话表示负数 return 0; }
每天更新pyQt5内容