在C艹中有两种字符串形式, 一种是C-风格, 另一种是C艹风格的
初始化:
char str[10] = {'a', 'c', 'd', ' '};
char str[20]= “aaa”;
string str = "aaa";
#include <iostream> #include <cstring> int main(int argc, char const *argv[]) { /* code */ using namespace std; const int Size = 15; char name1[Size]; char name2[Size] = "C++owboy"; std::cout << "name2 is :" << name2 << ' '; std::cout << "name1 :"; std::cin >> name1; std::cout << "hi, " << name1 << ' '; std::cout << "name1 strlen is : " << strlen(name1) << ' '; std::cout << "sizeof (name1) value: " << sizeof (name1) << ' '; std::cout << name1[0] << ' '; name2[3] = '