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 6660543
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T02:10:06+00:00 2026-05-26T02:10:06+00:00

I am trying to replace a substring with char*, the strng::replace refuses to take

  • 0

I am trying to replace a substring with char*, the strng::replace refuses to take anything that is not a const string *

   map<string,char *> renamed_files;
   map<string,char *>::iterator rename_it;

Is there any way of using cPath to replace the substring in the map?

   rename_it = renamed_files.begin();
   char cPath[1024];
   string strpath = cPath;
   rename_it->first.replace(0,len, strpath);
  • 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-26T02:10:07+00:00Added an answer on May 26, 2026 at 2:10 am

    No, the key in a map is const. Therefore the problem is that rename_it->first is const but replace is (of course) a non-const member function.

    If you were to somehow modify it, that would change the correct position of the entry in the map, but the map has no way to detect that you’re changing the string, so it can’t move the entry. To avoid the whole problem, modification is forbidden.

    You can remove the entry and add a new one with a different key but the same value. Be careful about the validity of your iterator as you do so.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to replace a substring that contains the char $. I'd be glad
How can I replace it? I've been trying this: string.replaceFirst(substring, ); but it's not
I'm trying to replace the programs that run from my startup directory with a
I am trying to replace the backslash (escape) character in a Javascript string literal.
Ok - am trying to create a string library that contains a handful of
char *strtok(char *s1, const char *s2) repeated calls to this function break string s1
I've been trying to replace to following string using the following... var r =
When trying to replace the content of an XML file in C#.NET with a
I'm trying to replace each , in the current file by a new line:
I'm trying to replace every multiline import inside a Python source file.. So, the

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.