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.