printf and puts
Newbie here .
Whats the difference between 'printf' and 'puts' . Isnt it better to use 'puts' for basic printing of characters as one would'nt have to type \n .
I love the videos here :)
Forum Rules/Features
Welcome to the WiBit.net forums! Check out our terms and features:
Hot Topic(s)
Annoy your friends
Is this something you think someone else would enjoy? Is it not for you, but do you know someone who is down with this type of content? Well share away:
Tweet
The Blog
Don't Let XML Make You a Cheater
This blog is a reminder that cheating in software development can get you into big trouble. Sometimes developers get really really lazy, OR are pressured to write something using overly simplified data structures. Almost every time this happens you are bitten in the butt! Sometimes the problems show up immediately and other times it may take months or years (especially in integrated systems).
- 1 of 78
- ››









"puts" is definitely quick and convenient! The big difference is that printf has a format string option.
You can also argue that puts is a little safer. If for example, you pass user input into a "printf" or an "sprintf" function on accident such as:
printf(userinput);
Instead of:
printf("%s", userinput);
The user can maliciously format the input string and hack your application (exploit a security vulnerability).
Here's a nice wiki page on string vulnerabilities:
http://en.wikipedia.org/wiki/Format%5Fstring%5Fvulnerabilities
Bryan