© Thomas Mailund 2021
T. MailundPointers in C Programminghttps://doi.org/10.1007/978-1-4842-6927-5_7

7. Strings

Thomas Mailund1  
(1)
Aarhus N, Denmark
 

Strings are little more than pointers to a sequence of characters, which we require is terminated by the zero character '\0'. There is even less language support for strings as a type than there is for arrays. You have syntax for creating literal strings, but beyond that, a string is indistinguishable from any other pointer to char. That strings are zero-terminated is a protocol, an expectation of functions that work with strings, but it is not enforced by the language in any way or form.

With strings, you can define an immutable string using double quotes (immutable because it is undefined what will ...

Get Pointers in C Programming: A Modern Approach to Memory Management, Recursive Data Structures, Strings, and Arrays now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.