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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T19:57:10+00:00 2026-05-23T19:57:10+00:00

Below is the section I am having trouble with if(transition == *(vec.end()-1)) { //vec

  • 0

Below is the section I am having trouble with

        if(transition == *(vec.end()-1)) { //vec contains the ASCI code
            vec.pop_back();
            --vec_index;
            result.append(vec[vec_index]);
        } else if(colors.find(modified.substr(1)) == colors.end()) {
            cout << result << endl;
            cout << "\033[0;37m";
            cerr << "**ERROR: INVALID CLOSING COLOR TAG ON LINE: "
            //cerr << "**ERROR: OVERLAPPING CLOSING COLOR TAG ON LINE: "
            << nlines << endl;
            exit(0);
        } else {
            cout << result << endl;
            cout << "\033[0;37m";
            cerr << "**ERROR: INVALID CLOSING COLOR TAG ON LINE: "
            //cerr << "**ERROR: OVERLAPPING CLOSING COLOR TAG ON LINE: "
            << nlines << endl;
            exit(0);
        }

In the above code, my else-if statement does not seem to execute at all. What I am trying to do is when modified.substr(1) is not found in the map is print the first error otherwise (the color string is in the map but it’s not the same one as the last one in the vector) print the “else” error. However, my else case is always printing. The reason why it’s modified.substr(1) is because modified (in this case) starts with a /.

  • 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-23T19:57:12+00:00Added an answer on May 23, 2026 at 7:57 pm
    transition = colors[modified.substr(1)];
    

    will create an entry in map<> color; if it’s not existing and value initialize it. That’s why your else if condition will never be true. Use map::find instead of operator [] to find the entry. Something like,

    map<string,string>::const_iterator it = colors.find(modified.substr(1)];
    

    And use it instead of transition. You can de-reference it (as it->first for key and it->second for string-value) when needed to get the underlying string.

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

Sidebar

Related Questions

I'm having trouble figuring out my last section of code for a Dynamic Coin
I am having trouble figuring out what the code segment below is doing. It
I'm having some trouble solving the problem below (My thinking on how I might
I am having some trouble with a nav section on a site which is
I'm having a (probably super simple) issue. The code below is supposed to _POST
I am having trouble running the following code. Not sure if I am doing
With the below code I'm creating a fetch request. The problem I'm having is
I am having below code in VBScript ' Retrieve the keyword category for page
I'm having trouble changing the section header for my grouped uitableview. I have tried
I am having trouble updating a partial that contains a nested_attributes_for form with AJAX.

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.