Actually your code is pure C not C++.

Anyway, this particular code should not give us any output. So it's quite a mystery how did you get this "0 1 2 0".
What compiler are you using?