+ 1

Why should we yous gets() and puts() function instead of using scanf() and printf()?

it is same or different function?

4th Apr 2017, 7:29 AM
kanchan kadam
kanchan kadam - avatar
2 Answers
+ 16
scanf() considers an input upto whitespace, and gets() take upto a new line. Suppose the user input is "Hello World", gets() will take "Hello World" scanf() will take "Hello" puts() appends a new line after the string output, but printf() doesn't.
4th Apr 2017, 8:57 AM
Shamima Yasmin
Shamima Yasmin - avatar
+ 5
It might be better to use gets() and puts() when you are working with char arrays. But you should avoid using gets() because it can cause errors, so use fgets() instead. Read this why you shouldn't use gets(): http://stackoverflow.com/questions/4346598/gets-function-in-c
4th Apr 2017, 7:38 AM
Eligijus Silkartas
Eligijus Silkartas - avatar