Well, I am not trying to be your enemy of course and the only person I get angry at is Mario F., who has the good sense to stay out of the C forum
But when I wrote "absolute worst practice" I did mean it.
I am just saying, as someone who could potentially help you out, how you can get the best out of a forum, based on my experience. I am doing that
because I recognize you are new. I understand that you may have "thought it could be sufficient to solve my problem" (maybe it is!); what I am telling you is that it would be better to think about how you can ask a question "in the best way", and not assume that things like desired outcome and actual outcome are irrelevant or superfluous:
How To Ask Questions The Smart Way
If you look under "translations", you will notice that has been translated into more than 20 languages, which is 19 more than 95% of actual programming tutorials. I wonder who thinks this is so important and why?
Now, I compiled and ran your last posted code. Here is the output:
10203040
That is exactly what I would expect, so what are you complaining about? Other than the fact that main() should always be of type int and return an int value, there is nothing wrong with your code.
I will take another guess: you are using an MS IDE, and the window closes right away?