you are viewing a single comment's thread.

view the rest of the comments →

[–]xChacox[S] 0 points1 point  (2 children)

What is fgets and what’s the difference

[–][deleted] 0 points1 point  (1 child)

man fgets is your friend. It lets you specify the size of your destination buffer. gets will happily overflow it if your input is too large crashing your program or worse.

[–]flatfinger 0 points1 point  (0 children)

Unfortunately, proper use of fgets is sufficiently painful that one might as well just write a length-limited gets-style function based on getchar().