在托管C ++逐字字面? (如C#的@"等等")字面、QUOT

2023-09-04 00:32:23 作者:久不遇

有没有办法在托管C ++使用逐字字符串?类似于C#的

 字符串文档= @C:\ Documents和Settings \
 

解决方案

在C ++ 11,有原始的字符串:

  COUT<< R((\DDD \ AA)\ n)的<< ENDL;
COUT<< R分隔符((\DDD \ AA)\ n)的分隔符<< ENDL;
 
°

输出为:

 (\DDD \ AA)\ñ
(\DDD \ AA)\ñ
 

Is there a way to use verbatim String literals in managed C++? Similar to C#'s

String Docs = @"c:\documents and settings\"

解决方案

in C++11, there is raw string literal:

cout<<R"((\"ddd\aa)\n)"<<endl;
cout<<R"delimiter((\"ddd\aa)\n)delimiter"<<endl;

output is:

(\"ddd\aa)\n
(\"ddd\aa)\n