Why not confirm what it is doing by displaying the value of the pointer? You'll see clearly what it is doing then.