Jump to content
  • Advertisement

Archived

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

bigwiger

Allocating memory problem

This topic is 5594 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

Ok - I have a special structure in my program which holds an array of chars. I then have a class that has one of these structs, and when the class is initialized, so is the array of chars. When I debug the program, the char array in the structure is allocated, and does acutally store values to it, but then when I try to use the structures array, it crashes because it can''t find a value in the array, even though it has been allocated. Anyone know what the problem could be?

Share this post


Link to post
Share on other sites
Advertisement
Code?

edit:
Struct with array in class.


struct sChars
{
char *array;
sChars(){array = new char[5];}
~sChars(){delete[] array;}
};

class cMyclass
{
public:
sChars *myarray;

cMyclass(){myarray = new sChars();}
~cMyclass(){delete myarray;}
};



[edited by - honayboyz on June 3, 2003 8:55:46 PM]

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!