What does this error mean?

Unhandled exception at 0x011c2416 in myProject.exe: 0xC0000005: Access violation reading location 0x00000018.

I am on a mac using a vitural machine runing windows 7 and on that I am using visual studio 2010. I don't know how relevant that is in this case but I thought I should supply it.

The program I am writing uses 2 headers 2 cpp and a main. It reads in a file with information using the ifstream in;

When I try to "debug" the file I get the error at the top and am prompted to either "break" or continue.

I am quite new to this and would appreciate any help possible.
closed account (zb0S216C)
It means that you're de-referencing a null pointer, which isn't a valid address.

Wazzak
Access violation reading location 0x00000018

When you get this message, it usually means you are trying to read from a bad pointer. In this case, since the address is near zero, it tells me you are trying to access a member of a class or struct, but the this pointer is null.

Something like this would cause a similar error:

1
2
3
4
5
6
7
8
9
10
11
struct foo
{
  int a[8];
  int b;
}

int main()
{
  foo* badptr = 0;
  int makeitcrash = badptr->b;  // <- access violation here
}


The debugger should take you to the line causing the crash. If it takes you to some STL code or some disassembly, you can move up on the call stack until you get to your code. Once you see what line of code is causing the problem it should be easy to fix.


EDIT:

ninja'd :(
Last edited on
Topic archived. No new replies allowed.