I am just curious why in the C programming language the function to read formatted input was called "scanf" as opposed to "readf". I assume it is derived from an earlier language, so in that case why was it named that way in the earlier language? (Recurse.)

Also, why "printf" rather than "writef"? In languages other than C, why "print" or "write" rather than "display"?

3 Answers 3


Printf is "print - formatted". It has the same root as "print" in "printer", which is shorthand for "teleprinter", a synonym for "teletypewriter", and comes likely from the time when you used real TTYs for interacting with computers instead of monitors and keyboards.

Scanf is "scan - formatted", and matches the "print" paradigm, compare to the use of "scanner" in the context of OCR. Also, one could assume that read/write have been a pair of system calls for a long time, and in the same way as printf is distinct from write (2), there has been desire to separate scanf from read(2).


"Read" actually requires comprehension of what you are looking at. As opposed to "Scan", which basically means to capture the input, then I will figure out what to do with it later.

  • Nice. Do you have any idea if this was something considered by the creator of the C language or a parent language, or is this just something that makes sense? Also, why do you think some languages use print instead of write or display?
    – Anonymous
    Nov 29, 2011 at 6:21
  • 1
    I think a lot of this has its origins back in the days of yore, when everything was done with punchcards (and stone tablets :) too). If you think in that context scan/print make more sense than read/write.
    – Craig T
    Nov 29, 2011 at 6:56
  • 1
    I don't agree that "read" in the computing sense requires comprehension of what you are looking at. I believe it means to blindly copy 1's and 0's from one place to another, for example, from the disk into memory. There's no comprehension involved. Nov 29, 2011 at 10:20
  • From a computing sense you are right, but not from a human sense.
    – Craig T
    Nov 29, 2011 at 11:24

This is an answer that is just "intuition". The name readf() assumes you already have something to read. But scanf() actually has two things to do: Wait for the user input (in other words, keep scanning the input buffer till it finds something) and then read it. Note that I'm not judging how the operating system actually implements that, I'm just describing the conceptual operation.

I know you'll tell me fscanf() and sscanf() do not match this idea, but I assume they are extensions to scanf() and thus it was just "normal" to give them the same name.

By the way, why is your name "Doug" and not "ABCD"?? :-P

  • I was actually wondering if there was a sight-sense-equivalent to "listen". We can "hear" but also "listen", we can "read" but as far as I know there is no word for "wait for someone to write something and then read it". Perhaps scan is this word.
    – Anonymous
    Nov 29, 2011 at 6:25
  • From dictionary.com definition 3 of scan: to peer out at or observe repeatedly or sweepingly, as a large expanse; survey.
    – Anonymous
    Nov 29, 2011 at 6:26
  • So, this dictionary definition supports my claim I guess. It's close to what the function is supposed to do.
    – OmarOthman
    Nov 29, 2011 at 6:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.