
本文共 3741 字,大约阅读时间需要 12 分钟。
C++ ������������������������������
������
���������������������������������������������������������������������������������������������������������������������������������������
������������
long productIds[199];productIds[0] = 20;productIds[1] = 30;productIds[2] = productIds[0] * productIds[1];
���������������������������������������������������������������������������������������������������������
int number[4] = {3, 6, 9, 12}; // ���������������int productIds[4]; // ������������������������������0float values[5] = {5.0, 2.1}; // ������������float totals[200] = {}; // C++ 11+ ������������������������������������0
���������������C++ 11
���������������������������������{}
���������������������������������
���������������������
���������������������������������������������������������//
������������������������������BETTER������������������
double c11_values1[4] {1.2, 3.3, 4.4, 5.5}; // ���������������double c11_values2[] {1.2, 3.3, 4.4, 5.5}; // ������������
���������
������������������������������������������������������������������������������������������������������������������
1. C���������������������������������
char str1[6] = {'a', 'b', 'c', '\0', 'e', '\0'}; // ���������������cout << str1; // ������ abccout << *(str1 +4); // ������'e'
������������������������������std::cin
������������������
char name[20]; // ���������9���������������������int size = 10; cout << "���������������������������";cin >> name;cout << "���������������" << name << endl;
���������������������������������������������get
������������������
2. ���������������
char str6[] = "abc" "def"; // ������������ abcdefcout << "���������������" << str6 << endl;
���������������������������������������������pstr
���
3. ���������������������
cout << strlen(str4) << endl; // ������������������������������������
���������������������������������������������������������strlen
���������������std::string
������������
4. ������������������������������
int n = strlen(str4);for (int i=0; i
5. ������������������������������
������std::cin.get()
���������������������������������������������������
char s[20];cout << "������������������������";cin >> s;cout << "���������������" << s << endl;
���������������������������������������������������������������������������������
cin >> name; // ���������������������������������������������cin >> '\n'; // ���������������
������������std::getline
������������������������������������std::string
���������������������������
���������������
���������������
C++������������+=
���������������������������������
string str = "abc";str += "def"; // ������ str = "abcdef"
������C������������������������strcat
���������������������������������������������
������������������������C���������������std::string
������������������std::string::append
������������������������C������������������strncat
���������������������������
���������������������
int strLength = str.size(); // ���������������int cStrLength = strlen(str); // ������������
���������������Raw String
���C++ 11
������������������������������������������������������������������������������������
string unicodeStr = "������"; // UTF-8char8 pinkStr[] = "���"; // UTF-16Codechar32_t high kariStr[] = L"������"; // ���������UTF-16���������������
Raw String
Raw������������������������������������������������������������������
cout << "Hello \nWorld" << endl; // ���������Hello Worldcout << R"(Hello \nWorld)" << endl; // ������������������
���������������String������Adjusting:
cout << R"((Hello \n (aa)\n \World))" // ������������������������������
���������������������������������������������������������������������������������������������������������������������������������������������������������������
发表评论
最新留言
关于作者
