Allocating memory problem

Started by
0 comments, last by bigwiger 20 years, 10 months ago
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?
Disgruntled designers are always the best ones
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]

This topic is closed to new replies.

Advertisement