A C program calls `printf()`. Which layer does `printf()` belong to, and which interface does that make it part of?
A C program calls `printf()`. Which layer does `printf()` belong to, and which interface does that make it part of?
Answer
The language libraries, and therefore the API
Options - A. The language libraries, and therefore the API - B. The system call interface, and therefore the API - C. The applications layer, and therefore the AUI - D. The kernel, because it eventually writes to the terminal Why - A. Correct — it is C library code running in your process, which then issues a `write` system call underneath. - B. The commonest confusion. `write` is the system call; `printf` is the library wrapper that formats your arguments and then calls it. - C. The AUI is what a person types at a prompt. Nobody types `printf()` at a shell prompt. - D. `printf` causes kernel work but is not kernel code; it runs in user mode in your own address space.
Sarwar & Koretsky 3e ch1 §1.7