Dynamic Memory Issue

Jun 29, 2015 at 3:46am
So i've just gotten around to researching dynamic memory allocation and it could be that its 4am but im confused.

http://pastebin.com/gC7hQeuF

In the function expand(), i have absolutely no idea why that for loop works. When it runs the first time should it not evaluate to false? On the first run through the loop i = 0 and length = 0, so how can i < length evaluate to true and run the loop? If i put i <= length it gives me an access violation error.

Thank you for any help in advance
Jun 29, 2015 at 4:05am
It doesn't run the for loop the first time.

All the for loop is doing is copying the old array to the new array, the first time there is nothing to copy so it doesn't matter.
Jun 29, 2015 at 4:54am
Yep i should get some sleep :D. Thank you.
Last edited on Jun 29, 2015 at 4:54am
Topic archived. No new replies allowed.