Advertisement

Access violation

Started by August 23, 2003 11:54 PM
5 comments, last by djd82983 21 years, 6 months ago
When I run this code I get an error: #include <gl\glaux.h> AUX_RGBImageRec *RGBImage; void main(void) { RGBImage->sizeX=128; } The error says Unhandled exception in blah.exe: 0xC0000005: Access violation. Any ideas?
RGBImage is a pointer. You''re trying to use a pointer that doesn''t point anywhere, thus, you''ll get an access violation.

Gotta use something like

AUX_RGBImageRec *RGBImage = new AUX_RGBImageRec;

or perhaps even

AUX_RGBImageRec *RGBImage = auxDIBImageLoad("filename")
Advertisement
I tried it and I''m getting the same error

#include <gl\glaux.h>

AUX_RGBImageRec *RGBImage = new AUX_RGBImageRec;

void main(void)
{
RGBImage->sizeX=128;
}

Nevermind.. I don''t know what happened, but I tried it again and it said the C++ file I had wasn''t included in the project. I don''t know what the hell is going on anymore. BTW It worked, thanks for the help!
I hope you plan on cleaning that memory up after you''ve finished with it.

delete RGBImage;
Good call. Memory Leaks bad

I will admit, I''m just starting C++. I''ve been working with VB mostly, so there are a lot of new things like memory allocation and pointers. I''d rather teach myself or learn from others rather than go to school for it. I seem to get a better handle on it that way. I appreciate everyone''s help.
Advertisement
You know, buying a good book wouldn''t go a miss...

You have to remember that you''re unique, just like everybody else.
If at first you don't succeed, redefine success.

This topic is closed to new replies.

Advertisement