+ 4

Is there any difference between gets and scanf

3rd Jun 2019, 8:17 PM
#멜젠
#멜젠 - avatar
3 ответов
+ 4
The main difference between them is:scanf() reads input until it encounters whitespace, newline or End Of File(EOF) whereas 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.
6th Jun 2019, 5:06 AM
Vapa Annayev
Vapa Annayev - avatar
+ 3
Scanf stops reading the input when it encounters a whitespace, while gets doesn't; and gets is only used to get strings, while scanf can be used to get any datatype
3rd Jun 2019, 8:22 PM
Airree
Airree - avatar
+ 1
Thxs Vepa
6th Jun 2019, 11:49 AM
#멜젠
#멜젠 - avatar