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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T04:53:41+00:00 2026-06-08T04:53:41+00:00

I am reading contents of a .dat file and populating an unordered_map this way:

  • 0

I am reading contents of a .dat file and populating an unordered_map this way:

bool FileManager::LoadSkillList(LPCSTR name)
{
    int counter = 0;
    std::ifstream myFile(name, std::ios::binary | std::ios::out );
    if(myFile.fail())
    {
        myFile.close();
        return false;
    }
    char skill[0x12C];
    ZeroMemory(skill,0x12C);
    char buff[100];
    while(counter != TOTAL_SKILLS)
    {
        myFile.read(skill,0x12C);

        if(myFile.gcount() < 1) continue;

        auto skillBlock = (SkillInfo*)&skill;

#ifdef _DEBUG
        char* skillName = skillBlock->szSkillName;
        int delay = skillBlock->delayTime;

        wsprintf(buff,"Skill Name: %s - Delay: %d\r\n",skillName,delay);
        Log(buff);
#endif

        this->skills.insert(std::make_pair(counter,skillBlock));

        if(myFile.gcount() > 0) counter++;
        myFile.seekg( counter * 0x12C);
    }
#ifdef _DEBUG
    Log("Skill count: %d\r\n",(int)this->skills.size());
#endif
    myFile.close();

    return (counter>0)?true:false;
}

When I try to retrieve the map values inside the LoadSkillList method, it works fine. But I have another method in FileManager class, that is accessed by other class, in order to retrieve the unordered_map value.

for(int skillNumber = 0; skillNumber < TOTAL_SKILLS; skillNumber++)
{
    auto fileDelay = fManager->getDelay(skillNumber);
}
// ...

int FileManager::getDelay(int n)
{
    auto block = this->skills.at(n);
    return block->delayTime;
} 

But somehow, my app crashs inside that method. (I am building an dll, and I checked it out with a debugger. )

Any clue of what is happening? Already tried with std::array, std::map with no success, both crash on the same method.

  • 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-08T04:53:43+00:00Added an answer on June 8, 2026 at 4:53 am

    I solved my problem doing this:

    declared skills as static.
    Adding values to the unordered_map like this:

            FileManager::skills.insert(std::make_pair(counter, new SkillInfo()));
        memcpy(this->skills[counter],skillBlock,sizeof(SkillInfo));
    

    Retrieving the desired value like this:

    int FileManager::getDelay(int n)
    {
    auto block = FileManager::skills[n];
    return block->delayTime;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am reading contents from JSON file and adding to div with unique IDs.
I am reading the contents of the file using fread into an char array.
I'm reading an xml file using Jaxb, now the contents of the xml file
I'm creating a Junit test file for my CSVreader. I'm reading the contents of
I am opening file in binary mode using fopen(abhi.zip,rb); and reading contents from it
I am reading the contents of a file into a 2D array. The file
Here is the contents of the text file I am reading All Guests Listed
I'm reading the contents from an XML file to show the web pages contents,
Consider the following piece of code for reading the contents of the file into
I am reading contents of a file and adding it as a row 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.