Hi Guys!
I need some guidance. How do I allocate a dynamic array in a structure? I am doing something like this
And then initializing array like thisCode:struct strArray { int size; int position; int *byteArray; };
But when I used boundschecker to detect memory leaks (the program compiles and runs fine) I get a memory leak statement onCode:int i = 32; strArray *source; strArray src; source = & src; source->byteArray = new int[i];
I am assuming I am doing something wrong here, because i then assign values to this array likeCode:source->byteArray = new int[i];
Again, any help and any comments on my style etc will be greatly appreciated as I am just starting out in this.Code:source->byteArray[0] = 30;
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.



LinkBack URL
About LinkBacks



But I console myself saying that i feel same way when I am starting out on new stuff and ask questions to experts. Thanks again!