how to declare char * with input of {“data”: “0001”}'

后端 未结 1 762
独厮守ぢ
独厮守ぢ 2021-01-27 08:29

my input data have this format { \"data\": \"0001\" }\'. when I declare as follows, in VC, it showed msg of \"user-defined literal operator not found\". how to declare and initi

相关标签:
1条回答
  • 2021-01-27 09:18

    From C++11 onwards, you have the option of using raw string literals.

    With that you will be able to do this:

    const char * u = R"({ "data": "0001" }')";
    

    If you cannot use C++11 features, then go for the old-fashioned way of escaping the double quotes like this:

    const char * u = "{ \"data\": \"0001\" }'";
    
    0 讨论(0)
提交回复
热议问题