Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6608693
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T19:38:12+00:00 2026-05-25T19:38:12+00:00

I am having problem formatting a string which contains quotationmarks. For example, I got

  • 0

I am having problem formatting a string which contains quotationmarks.

For example, I got this std::string: server/register?json={"id"="monkey"}

This string needs to have the four quotation marks replaced by \", because it will be used as a c_str() for another function.

How does one do this the best way on this string?

{"id"="monkey"}

EDIT: I need a solution which uses STL libraries only, preferably only with String.h. I have confirmed I need to replace ” with \”.

EDIT2: Nvm, found the bug in the framework

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T19:38:13+00:00Added an answer on May 25, 2026 at 7:38 pm

    it is perfectly legal to have the ‘”‘ char in a C-string. So the short answer is that you need to do nothing. Escaping the quotes is only required when typing in the source code

    std::string str("server/register?json={\"id\"=\"monkey\"}")
    my_c_function(str.c_str());// Nothing to do here
    

    However, in general if you want to replace a substring by an other, use boost string algorithms.

    #include <boost/algorithm/string/replace.hpp>
    #include <iostream>
    int main(int, char**)
    {
        std::string str = "Hello world";
        boost::algorithm::replace_all(str, "o", "a"); //modifies str
        std::string str2 = boost::algorithm::replace_all_copy(str, "ll", "xy"); //doesn't modify str
        std::cout << str << " - " << str2 << std::endl;
    }
    // Displays : Hella warld - Hexya warld
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm having this problem with validating a document that contains some basic PHP variables.
We are having problem with the server migration. We have one application that are
I'm having problem selecting an element with an id like this <li =0f:Bactidol_Recorder.mp4>. I
I'm having a strange problem with anchor tags shifting divs upwards which is causing
I've been scouring Google for an answer to this problem I'm having and have
I'm having a bit of a problem with serializing my .NET objects into JSON
I am having a problem with formatting the output from foreach loop. What should
Having problem with the middle Div not expanding to the width http://acs.graphicsmayhem.com/images/middiv.jpg Ok, how
We're having problem with a huge number of legacy stored procedures at work. Do
I'm having problem in the following line: rd.PrintOptions.PaperSize = PaperSize.PaperFanfoldStdGerman; it throws an exception

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.