Why we use gets() insteed scanf(). | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Why we use gets() insteed scanf().

String

23rd Mar 2019, 3:40 PM
Deepak Sharma
Deepak Sharma - avatar
2 Answers
0
//scanf() reads input until it encounters whitespace, newline or End Of File(EOF) // gets() reads input until it encounters newline or End Of File(EOF), gets() does not stop reading input when it encounters whitespace instead it takes whitespace as a string. //If u try to input : “ sample string” using both functions then scanf() will accept only “sample” and gets() will accept “sample string”. //So mostly used gets
23rd Mar 2019, 6:36 PM
Sudarshan Rai
Sudarshan Rai - avatar
0
Hey in function scanf we write the size and operator and many more types of products etc but in gets only we can write the address of value where the value is stored.
24th Mar 2019, 8:50 AM
Deepak Sharma
Deepak Sharma - avatar