The problem is in the use of the post-increment operator. Don't use it until you are completely familiar with its use because it will confuse you...............exactly as it just has done.