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++
热门推荐
10 感谢韩语老师祝福语简短
11 升职文案高级祝福语简短
12 花童结婚祝福语大全简短
13 向国庆送祝福语简短
14 什么寄语简短祝福语女生
15 客户回礼祝福语大全简短
16 女孩生日祝福语简短创意
17 家长回复节日祝福语简短
18 给外婆敬酒祝福语简短