Sololearn: Learn to Code
New course! Every coder should learn Generative AI!
Try a free lesson
+ 3
"A safer alternative to gets() is fgets(), which reads up to a specified number of characters. This approach helps prevent a buffer overflow, which happens when the string array isn't big enough for the typed text." I think this is the reason because when using "gets()", the size of the string you input may be larger than the capacity of the array, which will cause the error
20th May 2020, 6:13 AM
Zhengrong Yan
Zhengrong Yan - avatar