<s>
In	O
computer	B-General_Concept
programming	I-General_Concept
,	O
a	O
null-terminated	B-Data_Structure
string	I-Data_Structure
is	O
a	O
character	O
string	O
stored	O
as	O
an	O
array	B-Data_Structure
containing	O
the	O
characters	O
and	O
terminated	O
with	O
a	O
null	O
character	O
(	O
a	O
character	O
with	O
a	O
value	O
of	O
zero	O
,	O
called	O
NUL	O
in	O
this	O
article	O
)	O
.	O
</s>
<s>
Alternative	O
names	O
are	O
C	B-Language
string	I-Language
,	O
which	O
refers	O
to	O
the	O
C	B-Language
programming	I-Language
language	I-Language
and	O
ASCIIZ	B-Data_Structure
(	O
although	O
C	B-Language
can	O
use	O
encodings	O
other	O
than	O
ASCII	B-Protocol
)	O
.	O
</s>
<s>
Null-terminated	B-Data_Structure
strings	I-Data_Structure
were	O
produced	O
by	O
the	O
.ASCIZ	O
directive	O
of	O
the	O
PDP-11	B-Device
assembly	B-Language
languages	I-Language
and	O
the	O
ASCIZ	B-Data_Structure
directive	O
of	O
the	O
MACRO-10	B-Language
macro	O
assembly	B-Language
language	I-Language
for	O
the	O
PDP-10	B-Device
.	O
</s>
<s>
These	O
predate	O
the	O
development	O
of	O
the	O
C	B-Language
programming	I-Language
language	I-Language
,	O
but	O
other	O
forms	O
of	O
strings	O
were	O
often	O
used	O
.	O
</s>
<s>
At	O
the	O
time	O
C	B-Language
(	O
and	O
the	O
languages	O
that	O
it	O
was	O
derived	O
from	O
)	O
was	O
developed	O
,	O
memory	O
was	O
extremely	O
limited	O
,	O
so	O
using	O
only	O
one	O
byte	O
of	O
overhead	O
to	O
store	O
the	O
length	O
of	O
a	O
string	O
was	O
attractive	O
.	O
</s>
<s>
C	B-Language
designer	O
Dennis	O
Ritchie	O
chose	O
to	O
follow	O
the	O
convention	O
of	O
null-termination	O
to	O
avoid	O
the	O
limitation	O
on	O
the	O
length	O
of	O
a	O
string	O
and	O
because	O
maintaining	O
the	O
count	O
seemed	O
,	O
in	O
his	O
experience	O
,	O
less	O
convenient	O
than	O
using	O
a	O
terminator	O
.	O
</s>
<s>
This	O
had	O
some	O
influence	O
on	O
CPU	O
instruction	B-General_Concept
set	I-General_Concept
design	O
.	O
</s>
<s>
Some	O
CPUs	O
in	O
the	O
1970s	O
and	O
1980s	O
,	O
such	O
as	O
the	O
Zilog	B-General_Concept
Z80	I-General_Concept
and	O
the	O
DEC	B-Device
VAX	I-Device
,	O
had	O
dedicated	O
instructions	O
for	O
handling	O
length-prefixed	O
strings	O
.	O
</s>
<s>
However	O
,	O
as	O
the	O
null-terminated	B-Data_Structure
string	I-Data_Structure
gained	O
traction	O
,	O
CPU	O
designers	O
began	O
to	O
take	O
it	O
into	O
account	O
,	O
as	O
seen	O
for	O
example	O
in	O
IBM	O
's	O
decision	O
to	O
add	O
the	O
"	O
Logical	O
String	O
Assist	O
"	O
instructions	O
to	O
the	O
ES/9000	B-Device
520	O
in	O
1992	O
and	O
the	O
vector	O
string	O
instructions	O
to	O
the	O
IBM	B-Device
z13	I-Device
in	O
2015	O
.	O
</s>
<s>
FreeBSD	B-Operating_System
developer	O
Poul-Henning	O
Kamp	O
,	O
writing	O
in	O
ACM	O
Queue	O
,	O
referred	O
to	O
the	O
victory	O
of	O
null-terminated	B-Data_Structure
strings	I-Data_Structure
over	O
a	O
2-byte	O
(	O
not	O
one-byte	O
)	O
length	O
as	O
"	O
the	O
most	O
expensive	O
one-byte	O
mistake	O
"	O
ever	O
.	O
</s>
<s>
Due	O
to	O
the	O
expense	O
of	O
finding	O
the	O
length	O
,	O
many	O
programs	O
did	O
not	O
bother	O
before	O
copying	O
a	O
string	O
to	O
a	O
fixed-size	O
buffer	B-General_Concept
,	O
causing	O
a	O
buffer	B-General_Concept
overflow	I-General_Concept
if	O
it	O
was	O
too	O
long	O
.	O
</s>
<s>
However	O
,	O
this	O
does	O
not	O
always	O
result	O
in	O
an	O
intuitive	O
API	B-General_Concept
.	O
</s>
<s>
Null-terminated	B-Data_Structure
strings	I-Data_Structure
require	O
that	O
the	O
encoding	O
does	O
not	O
use	O
a	O
zero	O
byte	O
(	O
0x00	O
)	O
anywhere	O
;	O
therefore	O
it	O
is	O
not	O
possible	O
to	O
store	O
every	O
possible	O
ASCII	B-Protocol
or	O
UTF-8	O
string	O
.	O
</s>
<s>
However	O
,	O
it	O
is	O
common	O
to	O
store	O
the	O
subset	O
of	O
ASCII	B-Protocol
or	O
UTF-8	O
–	O
every	O
character	O
except	O
NUL	O
–	O
in	O
null-terminated	B-Data_Structure
strings	I-Data_Structure
.	O
</s>
<s>
UTF-16	O
uses	O
2-byte	O
integers	O
and	O
as	O
either	O
byte	O
may	O
be	O
zero	O
(	O
and	O
in	O
fact	O
every	O
other	O
byte	O
is	O
,	O
when	O
representing	O
ASCII	B-Protocol
text	I-Protocol
)	O
,	O
cannot	O
be	O
stored	O
in	O
a	O
null-terminated	O
byte	O
string	O
.	O
</s>
<s>
Many	O
attempts	O
to	O
make	O
C	B-Language
string	I-Language
handling	I-Language
less	O
error	O
prone	O
have	O
been	O
made	O
.	O
</s>
<s>
Another	O
is	O
to	O
add	O
an	O
object-oriented	O
wrapper	O
around	O
C	B-Language
strings	I-Language
so	O
that	O
only	O
safe	O
calls	O
can	O
be	O
done	O
.	O
</s>
<s>
Most	O
modern	O
libraries	O
replace	O
C	B-Language
strings	I-Language
with	O
a	O
structure	O
containing	O
a	O
32-bit	O
or	O
larger	O
length	O
value	O
(	O
far	O
more	O
than	O
were	O
ever	O
considered	O
for	O
length-prefixed	O
strings	O
)	O
,	O
and	O
often	O
add	O
another	O
pointer	O
,	O
a	O
reference	O
count	O
,	O
and	O
even	O
a	O
NUL	O
to	O
speed	O
up	O
conversion	O
back	O
to	O
a	O
C	B-Language
string	I-Language
.	O
</s>
<s>
Memory	O
is	O
far	O
larger	O
now	O
,	O
such	O
that	O
if	O
the	O
addition	O
of	O
3	O
(	O
or	O
16	O
,	O
or	O
more	O
)	O
bytes	O
to	O
each	O
string	O
is	O
a	O
real	O
problem	O
the	O
software	O
will	O
have	O
to	O
be	O
dealing	O
with	O
so	O
many	O
small	O
strings	O
that	O
some	O
other	O
storage	O
method	O
will	O
save	O
even	O
more	O
memory	O
(	O
for	O
instance	O
there	O
may	O
be	O
so	O
many	O
duplicates	O
that	O
a	O
hash	B-Algorithm
table	I-Algorithm
will	O
use	O
less	O
memory	O
)	O
.	O
</s>
<s>
Examples	O
include	O
the	O
C++	B-Language
Standard	B-Application
Template	I-Application
Library	I-Application
std::string	B-Language
,	O
the	O
Qt	B-Language
QString	O
,	O
the	O
MFC	B-Language
CString	B-Language
,	O
and	O
the	O
C-based	O
implementation	O
CFString	O
from	O
Core	B-Operating_System
Foundation	I-Operating_System
as	O
well	O
as	O
its	O
Objective-C	B-Language
sibling	O
NSString	O
from	O
Foundation	B-Operating_System
,	O
both	O
by	O
Apple	O
.	O
</s>
<s>
More	O
complex	O
structures	O
may	O
also	O
be	O
used	O
to	O
store	O
strings	O
such	O
as	O
the	O
rope	B-Data_Structure
.	O
</s>
