Why doesn’t scanf need an ampersand for strings and also works fine in printf (in C)?

scanf needs the address of the variable to read into, and string buffers are already represented as addresses (pointer to a location in memory, or an array that decomposes into a pointer).

printf does the same, treating %s as a pointer-to-string.

Leave a Comment