Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int main() {
- const int size = 4;
- char line[size] = { 'C', 'a', 't', '!' }; // символьный массив
- for (int i = 0; i < size; i++) {
- cout << line[i];
- }
- cout << endl;
- const int size2 = 5;
- char line2[size2] = { 'C', 'a', 't', '!', '\0'}; // строка (символьный массив, который заканчивается терминальным нулем
- for (int i = 0; i < size2; i++) {
- cout << line2[i];
- }
- cout << endl;
- int arr[5] = { 1,2,3,4,5 };
- cout << arr << endl; // так нельзя
- cout << line << endl; // так нельзя
- cout << line2 << endl; // а так можно (так как это строка, она заканчивается терминальным нулем)
- char line3[40];
- cin >> line3;
- cout << line3 << endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement