C Interfaces and Implementations: Techniques for Creating Reusable Software
by David R. Hanson - Princeton University
Chapter 16. High-Level Strings
The functions exported by the Str interface described in the previous chapter augment the conventions for handling strings in C. By convention, strings are arrays of characters in which the last character is null. While this representation is adequate for many applications, it does have two significant disadvantages. First, finding the length of a string requires searching the string for its terminating null character, so computing the length takes time proportional to the length of the string. Second, the functions in the Str interface and some of those in the standard library assume that strings can be changed, so either they or their callers must allocate space for string results; in applications that do not modify ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access