Interesting. Did you get any warnings from the compiler, such as "condition is always true"?

If not, try switching warnings to the maximum level, recompile the program with the error still in it, and see what it tells you. Warnings can be a good place to start looking for the reason for unexplained crashes.

I tried to spot the error in the code but I missed it. 1 looks too much like i. There should be a lesson for you here regarding choice of variable names. Well done for spotting the error yourself though. Debugging is probably 90% of programming - certainly over half - and too many people post here going "it crashes, find it for me, waaah" without realising they're throwing away half the "fun" of programming.