null-terminated string

From SEGGER Wiki
Revision as of 15:33, 7 July 2019 by Rolf (talk | contribs) (Created page with "Category:Knowledge Base A NULL-terminated string is a sequence of characters that ends with a character of 0. This is the standard string in C. Example: "Hello" is a 6 by...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

A NULL-terminated string is a sequence of characters that ends with a character of 0. This is the standard string in C. Example:

"Hello" is a 6 byte string, where the 5 visible characters are followed by a 0.
In memory, things look as follows: (Using hex representation)
48 65 6C 6C 6F 00

The null termination is expected by all string related routines in the C-standard library, such as strlen, strcpy.