C++ std::string 如何格式化带有多个双引号的字符串文字
C++ std::string how to format String literal with multiple double quotes?
我有一个 std::string 文字,双引号内有双引号,双引号内有双引号。我需要使用什么格式才能使其工作?下面是一个示例:
std:string http_command = "wget --post-data="user=bla password=bla query=select * from bla bla where username="" and name=bla" http:://example.com"
以下部分username=""
失败
谢谢大家。
更新:修复了我的示例,我在那里有一个额外的双引号。
std::string http_command = "wget --post-data="user=bla password=bla query="select * from bla bla where username="" and name=bla" http:://example.com"
转义除第一个和最后一个引号(分隔字符串的引号)以外的所有引号。
std:string http_command = "wget --post-data="user=bla password=bla query=\"select * from bla bla where username=\\\"\\\" and name=bla\" " http:://example.com"
有点猜测,但我认为你必须摆脱内部的反击。请注意,我认为您在帖子数据的末尾缺少引用。
相关文章:
- 我可以使用条件运算符初始化C风格的字符串文字吗
- 如何使用字符串文字作为宏参数
- 有没有办法从非C/C++文件中读取C++原始字符串文字的内容
- 构造<int>具有 2 个字符串文字的向量
- 初始化或分配空字符串文字到指向 C 中的 char 的指针或指向 C++ 中 const char 的指针的原因是什么
- 方便地对C++中的所有字符串文字进行模糊处理
- 比较 std::string 和 C 样式字符串文字
- 如何从char16_t字符串文字中读取双精度?
- 如何在 C 宏中将变量字符串与文字字符串连接起来?
- 我如何知道 boost::any 是否包含文字字符串
- C 专用模板功能接收文字字符串
- 如何使变量成为文字字符串
- 可以一个#define一个文字字符串,其中包含用于资源文件的非ANSI字符的字符串
- 从文字字符串生成编译时常量整数
- 当一个函数可以被赋予一个 char* 或文字字符串时,声明这个函数的正确方法是什么?
- 如何在 C 或C++宏中使用函数作为文字字符串
- GCC中可能的错误:结构中的文字字符串类型
- 文字字符串有效,但字符串在 file.open() 中不起作用
- C/C++:文字字符串中"xNNN"格式的固有歧义
- constexpr函数中声明为静态的文字字符串