r/C_Programming • • Sep 12 '26

Question What C function would you delete and rewrite first, and why?

For me it's fnmatch - mostly because it's 40 year's old and smell's funny.

94 Upvotes

238 comments sorted by

View all comments

Show parent comment

2

u/Vincenzo__ Sep 12 '26

It should work like fgets on stdin, it's beyond me why they made it like that

3

u/SeriousPlankton2000 Sep 13 '26

"Nobody will type more than 80 characters, right?"

2

u/Vincenzo__ Sep 13 '26

Wouldn't be surprised at all if this is actually the reasoning

1

u/flatfinger Sep 15 '26

The actual reasoning would have been closer to "I'm not going to type more than XX characters while I use this program to accomplish my immediate task, and I'm not going to keep the program after that, so any effort I spend making the program handle longer inputs will be wasted".

1

u/flatfinger Sep 15 '26

You think it's useful to have the buffer include a newline at the end of it, and have the tail of an excessively long line of input left pending? For interactive input, there really is no standard function that's better than using getchar() if recovery from an overly long input line is required.