By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,603 Members | 1,461 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,603 IT Pros & Developers. It's quick & easy.

Another on String

P: 11
In string what is the difference between

1 gets and scanf
2 puts and printf
Nov 10 '06 #1
Share this Question
Share on Google+
1 Reply

Expert Mod 5K+
P: 8,916
puts writes a string to stdout and appends a '\n', it does not format the string it has a fixed prototype

printf writes data to stdout, it doesn't automatically append a '\n' and it can write formated data, that is you can give it a format string and binary data and it will put the binary data into the output in the correct format.

gets and scanf act in a similar manor for input, however they are both unsafe functions. You shouldn't use either of them, instead use fgets.
Nov 10 '06 #2

Post your reply

Sign in to post your reply or Sign up for a free account.