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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T17:42:11+00:00 2026-05-24T17:42:11+00:00

I basically have exp>=level*10 in an else if expression, where level is a variable

  • 0

I basically have exp>=level*10 in an else if expression, where level is a variable and 10 is a constant number. The code compiles completely fine without any errors, and it even worked after being compiled, until recently. now, whenever it compiles and executes, it gives me an error saying “invalid null pointer” and it conveniently tells me that the problem comes from the included file xstring (VS2010 includes it in new projects) on line 930.
Is there a way to force to program to read it as the multiplication operator instead of a null pointer?
EDIT: Here is my full code, please note that this is a protype created to ensure that it will work and was done prior to me realizing I can use derived classes for this. also note that I tried removing using namespace std to see if that was the problem.

#include "stdafx.h"
#include <iostream>
#include <sstream>

class player {
public:
    std::string name;
    int hp;
    int attack;
    int strength;
    int defense;
    void reward(int gold, int exp) {
        player::gold += gold; 
        player::exp += exp;
        player::levelHandler();
    }
    int dataQuery(std::string query) {
        if (query == "equipment")
            return helm, armour, greaves;
        else if (query == "gold")
            return gold;
        else if (query == "exp")
            return exp;
        else if (query == "level")
            return level;
        else return 0;
    }
private:
    int helm;
    int armour;
    int greaves;
    int level;
    int gold;
    int exp;
    std::string levelHandler() {
        if (level==0) { 
            level=1;
        }
        else if (exp>=(10*level)) { //causes problem due to * being mistaken as a 
                    //null pointer.
        int previousLevel = level;
        level += 1;
        levelHandler();
        return 0;
        };
        return 0;
    };
} hero;

class enemy {
public:
    std::string name;
    int hp;
    int attack;
    int strength;
    int defense;
private:
    int helm;
    int armour;
    int greaves;
    int level;
    int goldReward;
    int expReward;
    int dataQuery(std::string query) {
        if (query == "equipment")
            return helm, armour, greaves;
        else if (query == "gold")
            return goldReward;
        else if (query == "exp")
            return expReward;
        else if (query == "level")
            return level;
        else return 0;
    }
};

int main()
{
    std::cout << "Please enter your character's name..." << std::endl;
    std::cin >> hero.name;
    std::cout << "Welcome to RPG Battle Simulation, " << hero.name << "!" << std::endl;
    hero.reward(100, 0); //problem is either this line, or the function's call to levelHandler, as this is where the program terminates.
    std::cout << "You are beginning your journey as a level " << hero.dataQuery("level") << " character." << std::endl;
    std::cout << "Here is " << hero.dataQuery("gold") << " gold to get you started." << std::endl;
    return 0;
};

The following is an excerpt of xstring that is causing the problem. the problem comes from _DEBUG_POINTER(_Ptr); (line 930)

_Myt& assign(const _Elem *_Ptr)
        {// assign [_Ptr, <null>)
 _DEBUG_POINTER(_Ptr);
 return (assign(_Ptr, _Traits::length(_Ptr)));
       }
  • 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-24T17:42:13+00:00Added an answer on May 24, 2026 at 5:42 pm

    This program reproduces your problem (when compiled with MSVC with runtime that supports debugging):

    #include <string>
    #include <iostream>
    
    int main()
    {
        using namespace std;
    
        string  s = 0;
        cout << s << endl;
    }
    

    The problem is that a std::string is initialized with a nullpointer.

    EDIT: oh, forgot to mention, solution – simply don’t do that.

    Cheers & hth.,

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

Sidebar

Related Questions

Basically I have some code to check a specific directory to see if an
I basically have a page which shows a processing screen which has been flushed
I basically have the following flow: XML -> JSON -> Spring MVC -> jsp
I am looking in to ways to enable a site to basically have something
I would like to do the following. Basically have a stored procedure call another
Basically I have a bunch of unmanaged VC++ static libraries. And the VC++ GUI
Basically I have the following class: class StateMachine { ... StateMethod stateA(); StateMethod stateB();
Basically I have a website. I have a properly setup sitemap so I assume
Basically I have a small template that looks like: <xsl:template name=templt> <xsl:param name=filter />
Basically you have two ways for doing this: for (int x = 0; x

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.