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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T18:27:26+00:00 2026-05-22T18:27:26+00:00

It seems normally people receive these errors when working with pointers, array, structs, etc.

  • 0

It seems normally people receive these errors when working with pointers, array, structs, etc. I’m getting it on every integer in a class, which confuses me. I’m sure I’m just missing some small technical detail (I’m a bit new to this).

The exact error is:

First-chance exception at 0x003e6616 in Mine.exe: 0xC0000005:
    Access violation reading location 0x00000008.
Unhandled exception at 0x003e6616 in Mine.exe: 0xC0000005:
    Access violation reading location 0x00000008.

The code breaks at the first line in this class method:

void Grid::Move(int x, int y)
{
this->offX+=x;
this->offY+=y;
for (int i=0;i<2;i++)
    for (int k=0;k<2;k++)
        BitmapSetxy(chunks[i][k]->map,this->offX,this->offY);
}  

Here is the constructor of Grid:

Grid::Grid()
{
totalW =320*2;
totalH = 320*2;
offX = 0;
offY = 0;

//Fill the chunks array with Maps to be used
for (int i=0;i<2;i++)
    for (int k=0;k<2;k++)
        chunks[i][k] = new Map(i*320,k*320);

//Everything starts as dirt
for (int x=0;x<(320*2)/20;x++)
    for (int y=0;y<(320*2)/20;y++)
        blocks[x][y] = bType::Dirt; 
}

And the header file:

#ifndef MapDef
#define MapDef

#include "Map.h"

class Grid
{
private:
int totalW, totalH;
int offX, offY; 
public:
enum bType
{
    Blank,
    Dirt,
    Copper
};

Map * chunks[2][2];
bType blocks[32][48];   
void RemoveBlock(int x, int y);
bType GetBlockAt(int x, int y);
int GetAbsolutePosition20(int);
int GetMapIndex(int);
int GetChunkRelative(int,int);
bType GetBlockBelow(int x, int y);
bType GetBlockAbove(int x, int y);
bType GetBlockSide(int x, int y, bool isRight);
void Move(int x, int y);
Grid();
};

#endif

When looking at the locals view of the current instance of Grid totalW, totalH, offX,offY all show the CXX0030 error, but the two arrays are perfectly fine. What exactly is going on here?

EDIT:

The definition of the grid pointer is stored in a separate little namespace that serves as something of a static class:

namespace Engine
{       
static Grid * grid;
static Player * player;
}

It is actually created here in the main cpp file:

//Initialize engine
Engine::grid = new Grid();
Engine::player = new Player(160,240);

Here is the excerpt where it is called, in another class called Player

    if (y>392 && y<480 && x>75 && x<152)
    {
        printf("Right");
        Engine::grid->Move(20,0);
    }

Edit 2:

I’m sorry, I forgot to remove the “static” keyword from the grid declaration in engine. I believe that was what was causing the 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-05-22T18:27:27+00:00Added an answer on May 22, 2026 at 6:27 pm

    According to the error message, your code is trying to access address 0x00000008, which is very close to 0. This means you probably have a null pointer of type Grid * somewhere and you are calling a function on it.

    You should either ensure that the pointer is not null, or check it. For example:

    Grid * grid = ...;
    if (grid == NULL){ return; }
    grid->move(0,1);
    

    Note that NULL is the same as 0.

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

Sidebar

Related Questions

It seems that it is impossible to capture the keyboard event normally used for
Seems to me most of developers completely ignore this features. People prefer handling security
Seems like every C# static analyzer wants to complain when it sees a public
I've started working on some Android applications and have a question regarding how people
I normally work these things out reasonably quickly, but this one is a headache.
normally I place my translations etc in properties - e.g. message_de.properties etc. I'm facing
I have a very simple class: People: class People { private string LastName =
Normally I would finalize a class at compilation via __PACKAGE__->meta->make_immutable at the end of
This seems simple enough. Elmah logs the errors, I see the error in the
Seems like a simple enough question but I can't seem to find the answer.

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.