Okay, this is subjective, but based on the principles of "cryptic naming" and "potentially misleading if you don't really understand it," my vote for the most confusing libc function name is:
mbrtowc
Here's why:
mbr: Looks like "member" at first glance. But it actually stands for "multibyte representation". Okay, that's already a bit obscure if you're not deeply familiar with character encodings.
towc: Means "to wide character". This part makes some sense, but you need to understand the distinction between multibyte encodings (like UTF-8) and wide character encodings (like UTF-16 or UTF-32 on some systems).
Overall: The name implies you're converting a single member to a wide character. In reality, it's decoding a sequence of bytes from a multibyte representation into a wide character, taking into account the current locale's encoding and potentially stateful encodings.
Why it's confusing:
Ambiguity: "mbr" has a common English meaning that clashes with its actual purpose.
Technical Jargon: You need to understand "multibyte character encoding," "wide character," and how locales affect character encoding.
Hidden Complexity: The function deals with stateful encodings (where the meaning of a byte depends on the previous bytes). The name doesn't hint at this.
Not Directly Obvious Purpose: Unless you're working specifically with internationalization and different character encodings, you're unlikely to stumble across this function and immediately understand what it does. Compare this to something like strlen or strcpy which are pretty intuitive.
Alternatives considered and why they fall short (slightly):
strtok: (String Tokenizer) - Potentially confusing for beginners, but at least "token" is a relatable concept, and the purpose of dividing a string is understandable.
setjmp / longjmp: (Set Jump / Long Jump) - Confusing if you don't know what they do, but their cryptic nature actually prepares you for the surprising control flow manipulation they perform. Also, "jump" at least provides a hint of what to expect.
ioctl: (Input/Output Control) - Confusingly general, but people quickly learn it's the "catch-all" for device-specific commands.
fgetc / fgets: (File Get Character / File Get String) - Seemingly simple, but they actually have subtle details about error handling and end-of-file detection that often trip up beginners. Still, the fundamental purpose is relatively clear.
In conclusion:
mbrtowc wins (in my opinion) because it has a name that sounds somewhat simple but hides a lot of complexity related to character encoding, locales, and stateful encodings. The name actively misdirects you until you really dig into the details.