双斜杠//在路径中-我可以使用单斜杠吗
Double slash // in paths - can I use single slash?
我有一个类似的VS模板
string mypath = "C:\custom\file.jpg";
我想用模板替换参数$userpath$制作C:\custom\部件。有什么办法可以避免使用双斜线吗?
我想写的是:
string mypath = SOMETHING("C:customfile.jpg")
不会用\c和\f进行转义并形成有效路径。有可能吗?
对于路径,您应该能够使用单个正向斜线作为分隔符:
std::string mypath = "c:/custom/file.jpg";
尝试一个原始字符串文字:
string mypath = R"(C:customfile.jpg)";
尽量使用双反斜杠字符,因为在c++中,所有解析器和编译器都能理解这一点。如果VS模板\
双反斜杠生成单反斜杠,请使用4反斜杠
\\
正确生成\
双反斜杠。
相关文章:
- 我可以更改将引用参数传递到指针中并使其正常工作的函数的输入(C、C++)吗?
- 我可以在使用 omp_set_num_threads 后使 OpenMP 恢复到理想的线程 # 吗?
- 我可以以某种方式使我的矢量/数组动态更改装置数量吗?
- 我可以在移动平台上有效地使用用C/C 编写的数字算法
- 我可以在 std::list 中移动元素而不会使迭代器或引用无效,但是如何移动呢?
- 任何人都可以帮助我使这个功能更有效
- 有哪些优化技巧可以使我的代码运行得更快
- 我可以在这里不使用线程同步吗?
- 语法错误,也想知道我是否可以使这段代码更有效率
- 我如何使用关系 btwn 3 整数来确定三角形和/或我可以使用什么声明来使这个程序工作
- 我可以使用字体表构建抽象访问者吗?
- 我可以在 Android Studio 中使用用 Xcode 编译的 C++ 静态库吗?
- 有人可以告诉我任何不同的方法来使这段代码更快
- 我可以禁止某些函数使程序崩溃吗?
- 是否可以使程序的执行跳过 fprintf-语句/如何创建我自己的 fprintf 函数
- 我可以使以下代码锁免费/原子吗?
- 仅仅使用(稳定的)第三方库就可以使我的代码无法工作
- 如何使一个回调全局,所以我可以使用它的其他功能
- 如何改变for循环,使我可以使用eof
- Qt-我在哪里可以找到我可以使用的字体列表