0

Why the function gets() in C more appropriate than fgets() to handle strings?

A question of a Sololearn challenge asked which function was better to get strings, and the correct answer was get() but in the options was fgets() too. The C tutorial explains both functions but suggested that fgets is safer than get() to handle strings, so I get a little bit confused.

2nd Jun 2020, 2:51 PM
Mic_2020_1_Luz_Pereira
Mic_2020_1_Luz_Pereira - avatar
2 odpowiedzi
+ 2
I think the quiz may be faulty; most of us know `gets` is rather "unsafe" and `fgets` or `scanf` can be used in its place.
2nd Jun 2020, 3:08 PM
Ipang