Overlapping Data Buffer
When using sprintf the same buffer must not be used both for output and input.
From this webpage: http://www.opengroup.org/onlinepubs/000095399/functions/printf.html
If copying takes place between objects that overlap as a result of a call to sprintf() or snprintf(), the results are undefined.
The behaviour vary depending on which compiler you are using. And it can also vary if you switch between debug/release builds or if you turn on various optimisations.