>> it doesn't work

In what way exactly? Does it compile? If not what errors do you get? If it compiles and runs, what input did you give, what output did you expect and what output did you get?

There are two very obvious errors: the while loop and the main function are not terminated. So this code shouldn't even compile. Also using should go outside the main function.

Have a close look at i, what you initialise it to, and where it gets changed and to what.