visual studio 2017 c ++原始字符串不起作用 [英] visual studio 2017 c++ raw strings does not work

查看:92
本文介绍了visual studio 2017 c ++原始字符串不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有"Visual Studio 2017社区"使用c ++。


我正在尝试使用原始字符串,如下所示:

使用System;使用System.Collections.Generic 

;
使用System.Linq;
使用System.Text;
使用System.Threading.Tasks;

namespace @string
{
class Program
{
string cloudformer_json = R"(
{
" AWSTemplateFormatVersion" :"2010-09-09",

....

)" ;;

然而它不承认"原始"字符串只是json代码。


我根据MSDN编写了原始字符串编码 


https://msdn.microsoft。 com / en-us / library / 69ze775t.aspx


我正在尝试使用原始字符串嵌入json代码,而不必使用转义字符 


有人可以告诉我如何让原始字符串起作用吗?



 

解决方案


您确定这是C ++吗?似乎是C#,你可以写下:

 string cloudformer_json = @" 
{
'AWSTemplateFormatVersion':'2010-09-09',
。 。 。
}" ;;

 string cloudformer_json = @" 
{
"" AWSTemplateFormatVersion"" :"""2010-09-09"",
。 。 。
}" ;;





I have "Visual Studio 2017 Community" using c++.

I am trying to use raw strings as follows:

using System;

using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace @string
{
    class Program
    {
        string cloudformer_json= R"(
 {
  "AWSTemplateFormatVersion" : "2010-09-09",

....

)";

However it does not recognize the "raw" string which is just json code.

I've based my coding of raw strings as per MSDN 

https://msdn.microsoft.com/en-us/library/69ze775t.aspx

I'm trying to use raw strings to embed json code without having to use escape characters 

Can someone tell me how I can get raw strings to work?

 

解决方案

Are you sure that this is C++? Seems C#, where you can write:

string cloudformer_json = @"
 {
  'AWSTemplateFormatVersion' : '2010-09-09',
  . . .
 }";

or

string cloudformer_json = @"
 {
  ""AWSTemplateFormatVersion"" : ""2010-09-09"",
  . . .
 }";



这篇关于visual studio 2017 c ++原始字符串不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆