在C ++中定义std :: string而不使用转义字符 [英] Define std::string in C++ without escape characters
本文介绍了在C ++中定义std :: string而不使用转义字符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
最简单的方法是将非转义字符序列输入 std :: string
?
What would be the most painless way to input un-escaped characters sequence to std::string
?
而不是
std::string st = "C:\\program files\\myFile.txt";
如下:(由于转义字符而无法正常工作)。
something like: (Doesn't work correctly due to escape characters).
std::string st = "C:\program files\myFile.txt";
推荐答案
对于文件名,只需使用另一个方向斜线。它也适用于Windows:
For filenames, just use (forward? back?) the other direction slash. It works on Windows too:
std::string st = "C:/program files/myFile.txt";
这篇关于在C ++中定义std :: string而不使用转义字符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文