Tearing apart printf()

5 years ago
ian $I9xuH7PGU4

http://www.maizure.org/projects/printf/index.html

If 'Hello World' is the first program for C students, then printf() is probably the first function. I've had to answer questions about printf() many times over the years, so I've finally set aside time for an informal writeup. The common questions fit roughly in to two forms:

Easy: How does the printf mechanically solve the format problem?

Complex: How does printf actually display text on my console?

My usual answer?

"Just open up stdio.h and track it down"