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

  • SEARCH
  • Home
  • 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 7832091
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T12:02:30+00:00 2026-06-02T12:02:30+00:00

I am running into some unexpected string behavior when I append an Iterator to

  • 0

I am running into some unexpected string behavior when I append an Iterator to a string. Basically, I have a file that reads something along the lines of:

int x := 10;
print x;

I have a string already that contains the contents of this file, and I am iterating through it and simply removing whitespace right now.

void Lexer::parse()
{
    Pointer = Filestring.begin(); // both private members
    while(Pointer < Filestring.end())
    {
        if(is_whitespace(0)) // 0 indicates current Pointer position
        {
            advance(Pointer, 1);
            continue;
        }

        CurToken.append(&*Pointer); // CurToken is private member string
        advance(Pointer, 1);
    }

    cout << CurToken << endl;
}

By the end of the loop I would expect CurToken to be a string that contains nothing but the characters with all whitespace removed. Instead I get something like the following:

int x := 1 + 2;
print x;



nt x := 1 + 2;
print x;



t x := 1 + 2;
print x;

…

rint x;



int x;



nt x;



t x;



x;



;

I assume the issue is de-referencing the pointer, and if so, how can I append the current pointer position’s character? If I do not de-refrence it, I end up with invalid conversion from ‘char’ to ‘const char*’

Note: is_whitespace() I have tested, and works as expected. So that can be ruled out as a possible problem.

  • 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-02T12:02:32+00:00Added an answer on June 2, 2026 at 12:02 pm

    What are the types of CurToken and Pointer? CurToken looks like a std::string. Is Pointer a std::string*? append has quite a few overloads. One of them is:

    string& append ( const string& str );
    

    If you want to hit that one you should get rid of the ‘&’ to give you just the dereferenced pointer:

    CurToken.append(*Pointer);
    

    That should work, but remember that it’ll append the whole string not just the character. If it doesn’t you probably need to figure out which overload of append() it’s hitting. If you want the first character only, try:

    CurToken.append(1, (*Pointer)[0]); 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm running into some curious behavior that I haven't seen before with javac and
I having been running into some strange problems with a webpage that I have
I'm running into some strange machine/OS dependent GZipStream behavior in .NET 4.0. This is
I have been trying to learn Erlang and have been running into some problems
Okay, so here's a problem I'm running into. I have some classes in my
I'm running into some problems with user-entered input that I want to send to
I am running into some C code that is using the getservbyname_r() function. I
I have been running into some issues with a JS script and have isolated
I'm running into some type of error here. Nothing is happening. Does anyone have
Running into some weird issues with didReceiveAuthenticationChallenge. If I do something like: NSMutableURLRequest *request

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.