Home

NULterminated

NULterminated refers to a string or character array in which the end of the string is indicated by a null character, typically the zero-valued byte '\0'. In this convention, the length of the string is not stored explicitly; instead, its end is determined by scanning forward until the first 0 byte is encountered.

NUL-terminated strings are most closely associated with the C programming language and the APIs derived from

Encoding and portability considerations: the terminator is a single zero byte, so ASCII and UTF-8 texts can

Limitations: embedded NUL bytes cannot appear within a NUL-terminated string, as any such zero would prematurely

See also: null character, C string, C standard library, string handling in C.

it.
A
character
array
or
pointer
to
char
is
assumed
to
be
terminated
by
a
terminating
zero,
and
standard
functions
such
as
those
in
the
C
standard
library
operate
on
these
strings.
This
representation
is
common
in
C
and
C++
when
interacting
with
legacy
code
and
system
interfaces.
be
represented
as
NUL-terminated
strings
as
long
as
embedded
zero
bytes
are
not
part
of
the
data.
While
the
terminating
byte
enables
simple
memory
layout
and
pointer-based
length
computation,
it
also
means
length
calculation
requires
scanning
the
data
and
introduces
potential
safety
risks
if
termination
is
corrupted
or
missing.
end
the
string.
In
modern
software,
alternative
representations
that
store
explicit
lengths,
such
as
length-prefixed
strings
or
dynamic
string
types,
are
often
preferred
for
safety
and
performance.
In
languages
like
C++,
std::string
maintains
its
own
length
and
can
be
converted
to
a
NUL-terminated
C-style
string
via
a
helper
method.