strcspn
Counts the characters before the first match of given characters. `buf[strcspn(buf, "\n")] = '\0';` removes the newline fgets leaves.
Counts the characters before the first match of given characters. `buf[strcspn(buf, "\n")] = '\0';` removes the newline fgets leaves.