[Home]
[Edit this page]
[Recent Changes]
[Special Pages]
[Help]
access violation
Access violation
A run-time ?error caused by the reading/writing to an illegal memory location.
This error mostly happens when working with [[array|arrays]]. Because it is a run-time error, it is nasty to debug. Also, these errors do not happen on every occasion, as sometimes they are not detected...
An example program that might give you an access violation:
The last line essentially being the same as:
Preventing access violations
[Edit this page] [Page history] [What links here] [Discuss this topic] [Printer Friendly]
access violation
Access violation
A run-time ?error caused by the reading/writing to an illegal memory location.
This error mostly happens when working with [[array|arrays]]. Because it is a run-time error, it is nasty to debug. Also, these errors do not happen on every occasion, as sometimes they are not detected...
An example program that might give you an access violation:
int array[10]; int * pArray = &array[0];
- (pArray+11) = 69;
The last line essentially being the same as:
array[11]=69;
Preventing access violations
- Prevent the use of ?pointer arithmetic (like in the example above), use array indexing instead.
- Prefer the use of vector over the use of an array.
- When using a vector, use either assert or the member function at(), which first does a ?range check for you.
[Edit this page] [Page history] [What links here] [Discuss this topic] [Printer Friendly]
