Pro lesson · Preview
Input & Output
How a program talks to the outside world. printf and scanf in C: format specifiers, common traps, and why the return value matters.
20 min read
This lesson is part of Pro
Upgrade to unlock the full lesson and the complete interview Q&A.
Unlock with Pro5 interview questions on this topic
Each one opens a full worked answer.
Why does scanf need an & in front of its arguments but printf doesn't?What does scanf return, and why should you check it?What's the difference between stdout and stderr, and when do you use each?You read a number with %d and then read a character with %c, but the %c doesn't wait for input. Why?Why is scanf("%s", name) dangerous, and what should you do instead?
This is just the start
Sign up free to track your progress through this course, mark lessons complete, and work through the full interview Q&A.
More in Programming Fundamentals
What Is a Program?Variables & Data TypesOperators
Conditionals
The switch Statement
while & do-while Loops