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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T21:07:20+00:00 2026-06-14T21:07:20+00:00

I have a pretty simple one for you today, but it certainly has had

  • 0

I have a pretty simple one for you today, but it certainly has had me stumped for hours. I imagine there is something wrong with the subtitles of my string iterator. I’ve looked online and even passed the code to my CSE professor – but what with it being thanksgiving break, he only had his phone and wasn’t able to be of much help.

Hopefully someone can look at this and immediately spot the problem. As a note, my goal is simply to remove special characters from a string. This string is passed into a function by reference (so a return type in not necessary). As an additional note, I am trying to keep this as efficient as possible. My original thinking was to simply shift this over to nested for loops, but my CSE prof maintains that a for loop with a string iterator inside is more efficient in some special cases, so I should stick with that. Please let me know if anyone can help!!

It seems to me the issue must lie in the remove function, as remove takes a const char *, not simply a char *. I assume that text.begin() is not const and therefore causes the issue. But if I make the the parameters of the function const string &text, we obviously cannot modify text by reference.

Here is the code I have so far:

in the main we have:

 string temp = "~cool~";
 XML * parser = new XML();
 parser->clearSpecialChars(temp);
 cout << temp;

and the function is:

void XML::clearSpecialChars(string &text)
{
    char chars[]= ".,!()1234567890[]'<>:/{}_|=+;-`~";
        for (unsigned int i = 0; i < 33; ++i)
        {
            text.erase(std::remove(text.begin(),text.end(),chars[i]),text.end());
        }
 }

however,I am getting a compiler error of:

 XML.cpp: In member function ‘void XML::clearSpecialChars(std::string&)’:
 XML.cpp:86:69: error: cannot convert ‘std::basic_string<char>::iterator {aka __gnu_cxx::__normal_iterator<char*, std::basic_string<char> >}’
 to ‘const char*’ for argument ‘1’ to ‘int remove(const char*)’

any thoughts would be greatly appreciated!

  • 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-06-14T21:07:21+00:00Added an answer on June 14, 2026 at 9:07 pm

    There are two functions called remove. Here are the description to each of them:

    http://www.cplusplus.com/reference/algorithm/remove/

    http://www.cplusplus.com/reference/clibrary/cstdio/remove/

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

Sidebar

Related Questions

I have a pretty simple case which I started solving using foreach(), but then
I have a pretty simple JSP/Servlet 3.0/Spring MVC 3.1 application. On one of my
I have a pretty simple question, but for some reason I am drawing a
I have a probably pretty simple question but I am still not sure! Actually
I have a pretty simple idea in mind but don't exactly know how to
I thought this would be pretty simple, but guess not. I have the following
This should be pretty simple, but I can't seem to get it. I have
I have a pretty simple problem, but right now can't seem to see the
I have a pretty simple collection, but I can't seem to bind to it's
i have a pretty simple captcha, something like this: <?php session_start(); function randomText($length) {

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.