n
n为换行符, 可被endl代替
下面代码没有使用任何换行符
输出结果为
123456
复制代码
1
2
3
4
5
6
7#include <bits/stdc++.h> using namespace std; int main(){ cout << 123; cout << 456; return 0; }
下面代码用了n, endl换行符
输出结果为
123
456
复制代码
1
2
3
4
5
6
7#include <bits/stdc++.h> using namespace std; int main(){ cout << 123 << "n"; cout << 456; return 0; }
复制代码
1
2
3
4
5
6
7#include <bits/stdc++.h> using namespace std; int main(){ cout << 123 << endl; cout << 456; return 0; }
t
t为tab, 可输出4个空格
下面代码用了t
输出结果为
123 456
复制代码
1
2
3
4
5
6#include <bits/stdc++.h> using namespace std; int main(){ cout << 123 << "t" << 456; return 0; }
" and '
"可输出单个双引号
'可输出单个单引号
下面代码用了"和'
输出结果为
"and'
复制代码
1
2
3
4
5
6#include <bits/stdc++.h> using namespace std; int main(){ cout << """ << "and" << "'"; return 0; }
\
\可输出一个反斜杠
下面代码用了\
输出结果为
复制代码
1
2
3
4
5
6#include <bits/stdc++.h> using namespace std; int main(){ cout << "\"; return 0; }
更多内容见表格
b | 删掉字符串前方的一个字母 |
v | 换行,并在第二行前边加一个tab |
最后
以上就是高挑外套最近收集整理的关于C++ 反斜杠( \ )用处\n\t\" and \'\\的全部内容,更多相关C++内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复