C ++中的原始字符串文字
在C++11及更高版本中,有一个称为Rawstring的概念。在字符串中,我们使用不同的字符,例如\n,\t等。它们具有不同的含义。\n用于将光标返回到下一行,\t生成制表符等。
如果我们想在输出中打印这些字符而看不到它们的效果,则可以使用原始字符串模式。为了使字符串成为原始字符串,我们必须在字符串之前添加“R”。
Input: A string "Hello\tWorld\nC++" Output: "Hello\tWorld\nC++"
算法
Step 1: Get the string Step 2: Use R before string to make it raw string Step 3: End
范例程式码
#include<iostream>
using namespace std;
main() {
string my_str = "Hello\tWorld\nC++";
string raw_string = R"Hello\tWorld\nC++";
cout << "Normal String: " << endl;
cout << my_str <<endl;
cout << "RAW String: " << endl;
cout << raw_string;
}输出结果
Normal String: Hello World C++ RAW String: Hello\tWorld\nC++
热门推荐
1 带狗狗训练
4 听力训练狗狗
6 怎训练狗狗
7 腹肌训练狗狗
8 网球训练狗狗
9 记叙文训练狗狗
10 狗狗太凶怎么训练
11 核心力量训练狗狗
12 狗狗乱叫怎么训练
13 发音训练狗狗
14 怎么训练狗狗叼东西给主人
15 荆州训练狗狗
16 篮球训练狗狗
17 做训练狗狗
18 训练狗狗坐姿