0

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.

2
Contributors
2
Replies
4
Views
6 Years
Discussion Span
Last Post by dotancohen
1

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.

Votes + Comments
Thank you. The word "etymology" is what I was missing when googling.
0

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.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.