C++的转义字符
1. 转义字符
① 用于表示一些不能显示出来的ASCII字符。
② 我们常用的转义字符有:\n、\、\t。
#include <iostream>
using namespace std;
int main()
{
//换行符 \n
cout << "hello world\n";
//反斜杠 \\ 要输出反斜杠\时,要在前面加上一个反斜杠
cout << "\\" << endl;
//水平制表符\t 可以整齐的输出数据
cout << "aaaa\thellowworld" << endl;
cout << "aa\thellowworld" << endl;
cout << "aaaaaa\thellowworld" << endl;
system("pause");
return 0;
}
运行结果: - hello world - \ - aaaa hellowworld - aa hellowworld - aaaaaa hellowworld - 请按任意键继续. . .