Why the function gets() in C more appropriate than fgets() to handle strings? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
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 Answers
+ 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