 <p>Hmmm, nice puzzle. FWIW: printf("%s 1 \n", str) prints ' 1 rty "what"' ?!? ... looks to me like what you are seeing on the console, right?) is:</p> <p>qwerty "what"</p> <p>followed by return (no line feed), overwritten by:</p> <p>' 1 '</p> <p>then \n</p> <p>This suggests that the string you are supplying (from a file?) includes a terminating return character.</p>