I cant figure out how the following loop can ever end:
for(int i;i<i+1;i++)
Overflowing a signed integer is undefined behaviour. Which manifests itself either in loop terminating or not.
Also, you do not initialize i
but access its value which is undefined behaviour as well.
signed integers are implemented using twos complement arithmetic, this has negative values when the top bit is set . When you do a the maximum positive value +1 you get the maximum negative value at which point the condition becomes false. This isn't defined by the C standard, but is very likely to be the case unless you are on odd hardware.