What people have failed to mention in other answers (so far) is the reason why scanf
wants you to pass addresses of values, while printf
wants you to pass the values themselves.
In some sense, there's no technical reason why printf
could not have been designed to take the addresses to values to print. If that were the convention, printf
would simply go look up what is at that address (using the pointer dereference operator, *
)...and print it.
Two things though:
- That dereference is an "extra step" which is not needed; because just having a copy of the value itself is enough to transmit the information to
printf
. C likes to avoid extra steps when it can.
- An address-based convention would prohibit using
printf
on literal values, which don't have addresses. You can't write printf("Value is %d", &10);
and have it print Value is 10
. This could be worked around by making a variable to store the value in and passing the address of the variable... but as I just said, C likes to avoid extra steps.
Yet with scanf
, there is a technical reason why an address is required, and not a value. It needs to receive a place to put the data, such that the caller can look at that data later.
Think about reading in integers, for example. If you passed in an integer value of zero (instead of the address of an integer variable) and that's all scanf
had to go on...how would it ever get the value it read back to you?
(In the particular example here, with an array of characters, there is a subtle issue regarding the lack of necessity of the address operator: see How come an array's address is equal to its value in C?...but ignore that and focus on the integer example for the concept. :-P)