Var declaration in the middle of the block is not good

Out code is plain C