Jump to content
  • Advertisement


This topic is now archived and is closed to further replies.


Access violation

This topic is 5474 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I have the following code:
struct ELEMENT {
	int				   x, y;
	float			   xSize, ySize;
ELEMENT* pElements;

miElements	  = 0;
pElements	  = new ELEMENT[miMaxElements];

ZeroMemory(&pElements, sizeof(pElements) * miMaxElements);

//Set the appropriate values in the structure

pElements[0].mptex = mptex;
pElements[0].x	   = x;
pElements[0].y	   = y;
pElements[0].xSize = xs;
pElements[0].ySize = ys;
On the first line ''pElements[0].mptex = mptex'' I get access violation. I know I''ve got something missing somewhere but I don''t know what or where!!!! Ideas?? Ivan

Share this post

Link to post
Share on other sites
.. and change the line

ZeroMemory(&pElements, sizeof(pElements) * miMaxElements);


ZeroMemory( pElements, sizeof(ELEMENT) * miMaxElements);

Thus you''re zeroing the memory pElements points to, plus sizeof( ELEMENT) gives you the wanted size not the size of one pointer.

Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!