Run-Time Check Failure #2 – Stack around the variable ‘foo’ was corrupted
Valid indexes for foo are from 0 to MAX-1 inclusive. MAX is past the end of the array. Your loop runs up to, and including, MAX. This writes beyond the end of the array, corrupting the stack. Either increase the array size to MAX+1 so that MAX is in range; or change the loop condition … Read more