Re: Null-terminated strings: the final analysis.
- From: Mark Wooding <mdw@xxxxxxxxxxxxxxxx>
- Date: Sun, 12 Apr 2009 13:13:08 +0100
Mark McIntyre <markmcintyre@xxxxxxxxxxxxxxxxxxx> writes:
Some of the above may be true - C++ and Java use a form of
byte-counted string. However note that C's model is likely to be the
most space-efficient for non-trivial sized string, as the storage need
be only one byte longer than the string, whereas byte-counted strings
must be at least one byte longer.
Of course, the relative overhead for large counted strings is
negligible, since the overhead is constant and the string is large.
What may be of more concern is the overhead for short strings, since
implementations typically use the same sized length field for all
strings. But even then the difference is unlikely to be particularly
significant in practice.
And none of this addresses the major defect of null-terminated strings,
which is that they can't represent strings containing a zero byte.
-- [mdw]
.
- Follow-Ups:
- Re: Null-terminated strings: the final analysis.
- From: CBFalconer
- Re: Null-terminated strings: the final analysis.
- From: Kenny McCormack
- Re: Null-terminated strings: the final analysis.
- References:
- Re: Null-terminated strings: the final analysis.
- From: Tony
- Re: Null-terminated strings: the final analysis.
- From: Mark McIntyre
- Re: Null-terminated strings: the final analysis.
- Prev by Date: Re: structure and union queries
- Next by Date: Re: Strange - a simple assignment statement shows error in VC++ but works in gcc !
- Previous by thread: Re: Null-terminated strings: the final analysis.
- Next by thread: Re: Null-terminated strings: the final analysis.
- Index(es):
Relevant Pages
|