Many functions in C have been "improved" with versions that have n, l, or other characters in their names. For instance, strncat and strlcat which improves strcat. What is the significance of the letter n or l in these names?

Thanks.

Recommended Answers

All 2 Replies

What is the significance of the letter n or l in these names?

The "n" means that the operation is bound by a character limit, with the limit being remaining available space in the destination (in the case of strncpy() and strncat()), or a partial string count (in the case of strncmp()).

I don't know the etymology of the "l" (note that the strl* functions are non-standard), but like the "n", it means that a character limit is provided to avoid buffer overflow. However, instead of the limit representing remaining available space in the destination, it represents the total size of the buffer, which greatly simplifies usage.

commented: Thank you. The word "etymology" is what I was missing when googling. +3

Thank you, Narue.

By the way, we raise our daughters on a variation of the excellent quote in your .sig. They are remarkably self-sufficient and intelligent for their ages as a result.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.