If you build with GCC, you should turn on all the warnings with -Wall and read them carefully.
The reason you get "strange" output is that you've violated printfs preconditions (passing arguments whose types do not match the format spec), and once you did, printf is free to do whatever it wants, including crashing, printing garbage, or melting your CPU.