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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T19:43:36+00:00 2026-06-14T19:43:36+00:00

I know where the error is in the following code, line 90, I just

  • 0

I know where the error is in the following code, line 90, I just cannot figure out why it would behaves the way it does:

 83   string
 84   getStringId(TokenType toktype)
 85   {
 86     map<TokenType, string>::iterator pos;
 87     pos = TokenTypeMap.find(toktype);
 88     string str;
 89     if(pos != TokenTypeMap.end()) {
 90       str = pos->first;
 91     }
 92     if(str.empty()) {
 93       cerr << "Error: Invalid TokenType: " << toktype << endl;
 94       exit(EXIT_FAILURE);
 95     }
 96     /* The following if block is only here for debugging */
 97     if(str.length() == 1) {
 98       cerr << "Error: String length == 1 :>" << str << "<:"<< endl;
 99       exit(EXIT_FAILURE);
100     }
101     return str;
102   }

On line 90 I assign a TokenType to a string. Since TokenType is an enumeration I was expecting something to go bang here due to strict typing but unfortunately there’s no warning at all due to it really being an int. The reason for this was found here:

Why does C++ allow an integer to be assigned to a string?

This is fine but, I noticed that the string is not empty and has a length of 1 as would be expected with a char. However, if I try and print it out online 98 I get

Error: String length < 2 :><:

Note there is nothing printed between the markers >

  • 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-14T19:43:37+00:00Added an answer on June 14, 2026 at 7:43 pm

    You didn’t tell us what the actual value was, but it’s probably an unprintable character in ASCII.

    This is a rather strange use of strings.

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

Sidebar

Related Questions

Question: I receive the following error for the code below, does anyone know why?
I get that error with the following code. anyone know why? function validateAdminInput(){ var
The following code returns an error and I dont know why: require rexml/document include
Does anyone know of a solution to the following markup validation error? I'm not
I am getting the following error on my site, however, i don't know what
I am receiving this mysql error and i don't know why. I am following
Does anyone know what error message will be displayed when someone tries to run
I'm getting the Syntax Error in input(1) error for this line of code, in
I just started learning how to write htaccess . I got the following code
I'm trying to create a new CodeType, the following code runs just fine in

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.