tags:
- c
- programming
- stack-overflow
- social-media
- notes
source: https://stackoverflow.com/questions/2454474/what-is-the-difference-between-printf-and-puts-in-c
created: 2024-09-12
published: 2010-03-16
What should you never do with printf
and why?
You should never use printf
with a variable as the first argument (like printf(variable);
) because an attacker can attack the program using formatted strings.
What is the difference between puts(variable)
and printf(variable)
?
The difference between puts(variable)
and printf(variable)
is that the first argument of printf
is interpreted as a formatted string.
It is generally ... and conceptually ... to pass a dynamic string as a single argument of ...
It is generally dangerous and conceptually wrong to pass a dynamic string as a single argument of printf
.