How Does printf Work?

An author at the Hostile Fork blog decided to answer a question on how the printf function actually gets implemented in C. This came from StackOverflow. It was assumed that it ended up with some inline assembly code. Let's see what he found out.

The truth of the matter is that it depends on the implementation of your compiler. Hostile Fork guy checked out the GNU C compiler. Turns out printf calls vfprintf with stdout as a parameter. vfprintf calls some macros. They do a putc to a buffered output.

In the end, the calls map down to the write function. And lo and beyond, this becomes a syscall. Next homework step is to trace how Microsoft Visual Studio handles printf.