Hi Guys!
I need some guidance. How do I allocate a dynamic array in a structure? I am doing something like this
Code:
struct strArray {
int size;
int position;
int *byteArray;
};
And then initializing array like this
Code:
int i = 32;
strArray *source;
strArray src;
source = & src;
source->byteArray = new int[i];
But when I used boundschecker to detect memory leaks (the program compiles and runs fine) I get a memory leak statement on
Code:
source->byteArray = new int[i];
I am assuming I am doing something wrong here, because i then assign values to this array like
Code:
source->byteArray[0] = 30;
Again, any help and any comments on my style etc will be greatly appreciated as I am just starting out in this.
Thanks in advance
-Sam
I have searched online and any link on a thread or online reference that will answer my question will also be helpful.