putchar() vs printf() - Is there a difference?

I compiled an example using printf("a") with -S and got call putchar in the assembly code.

Looks like when you have only one char in the printf the compiler turns it into a putchar().

I did another example using printf("ab") and got call printf, with the text section in the %edi register.


printf is a generic printing function that works with 100 different format specifiers and prints the proper result string. putchar, well, puts a character to the screen. That also means that it's probably much faster.

Back to the question: use putchar to print a single character. Again, it's probably much faster.