字符串类型
#include <iostream>
using namespace std;
#include <string>
int main() {
char str[] = "hello world";
cout << str << endl;
string str2 = "hello world";
cout << str2 << endl;
system("pause");
return 0;
}
字符型
#include<iostream>
using namespace std;
int main() {
char ch = 'a';
cout << ch << endl;
cout << sizeof(ch) << endl;
cout << int(ch) << endl;
system("pause");
return 0;
}
转义字符
#include<iostream>
using namespace std;
int main() {
cout << "hello world" << endl;
cout << "hello world\n";
cout << "\\" << endl;
cout << "aaa\thelloworld" << endl;
cout << "aaaa\thelloworld" << endl;
cout << "aaaaaa\thelloworld" << endl;
system("pause");
return 0;
}