Tearing apart printf()

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 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”

This wild goose chase is not only a great learning experience, but also an interesting test for the dedicated beginner. Will they come back with an answer? If so, how detailed is it? What IS a good answer?

This is incredibly detailed and definitely over my head, but I’m sure many of you will enjoy this one greatly.

11 Comments

  1. 2019-11-13 3:31 am
  2. 2019-11-13 3:53 am
  3. 2019-11-13 11:42 am
    • 2019-11-13 4:53 pm
      • 2019-11-14 12:29 am
        • 2019-11-14 3:34 am
          • 2019-11-14 6:32 pm
          • 2019-11-15 12:28 am
          • 2019-11-15 1:32 am
  4. 2019-11-13 11:42 am
  5. 2019-11-14 11:08 am