It does actually output the right value for n. You just haven't assigned any value to n, so you get garbage.
Oh sorry, I did do int n=2; on the compiler. I forgot to post it here since I wrote the example from scratch.
It still displays garbage for some reason.
EDIT: Hum, strange. I tried it on a new empty project and now it DOES display n correctly. Not sure why, or what made this happen, but at least it's fixed. But if I try it on the old project it still prints stuff like "0034EDDC", "0045EF9C". Guess I'll stick with a new project. Thanks, for the input.