The C programming language has a set of functions implementing operations on strings (character strings and byte strings) in its standard library. Various operations, such as copying, concatenation, tokenization and searching are supported. For character strings, the standard library uses the convention that strings are null-terminated: a string of n characters is represented as an array of n + 1 elements, the last of which is a "NUL" character.
The only support for strings in the programming language proper is that the compiler translates quoted string constants into null-terminated strings.
A string is a contiguous sequence of code units terminated by the first zero code (\0
, corresponding to the null character). In C, there are two types of strings: string, which is sometimes called byte string which uses the type char
s as code units (one char
is at least 8 bits), and wide string which uses the type wchar_t
as code units.
A common misconception is that all char
arrays are strings, because string literals are converted to arrays during the compilation (or translation) phase. It is important to remember that a string ends at the first zero code unit. An array or string literal that contains a zero before the last byte therefore contains a string, or possibly several strings, but is not itself a string. Conversely, it is possible to create a char
array that is not null-terminated and is thus not a string: char
is often used as a small integer when needing to save memory.
try, it’s not that hard,
to try to stop,
but you went too far,
too far from you.
cry, let them hear you cry,
turn your inside out,
then we will understand,
the other side of you
bodies hanging upside down,
at the edge of the town.
so you curse it all.
so to hell you’ll crawl,
fost and cold,
far from any other road.
you’re walking blind,
one step behind,
and where’s the spark,
it’s just a glow in the dark
so you curse it all
walking blind
one step behind
and where’s the spark
it’s just a glow in the dark
to hell you’ll crawl
lost and cold