This is exploding because you accidentally push i way past the bounds of the U array. It should have been easy to spot if you had spent as much time using a debugger as it took you to ask the question on Stack Overflow.

Email codedump link for Dynamic Allocation using a member in a structure