Re: Results of the memswap() smackdown from the thread "Sorting" assignment
- From: "Clive D. W. Feather" <clive@xxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Mon, 18 Feb 2008 12:13:15 +0000
In article <47B5C712.55AE336F@xxxxxxxxx>, CBFalconer
<cbfalconer@xxxxxxxxx> writes
[...]If we define a "string literal" as "characters between
non-escaped quotes" then C strings can contain nuls, as I showed.
We don't. From N869:
Actually, a "string literal" *is* "characters between non-escaped
quotes":
6.4.5 String literals
Syntax
string-literal:
" s-char-sequenceopt "
L" s-char-sequenceopt "
s-char-sequence:
s-char
s-char-sequence s-char
s-char:
any member of the source character set except the double-
quote ", backslash \, or new-line character
escape-sequence
Description
A character string literal is a sequence of zero or more multibyte
characters enclosed in double-quotes, as in "xyz". A wide string
literal is the same, except prefixed by the letter L.
As such, it can only contain a NUL if that is a valid character in the
extended source character set. Very probably it isn't.
The string literal "ab\0cd" causes the creation of an array of 6 chars
initialized with { 'a', 'b', 0, 'c', 'd', 0 }, but that isn't the string
literal, it's an array.
"string literal" is a compile-time concept. "string" is a run-time one.
--
Clive D.W. Feather | Home: <clive@xxxxxxxxxx>
Tel: +44 20 8495 6138 (work) | Web: <http://www.davros.org>
Fax: +44 870 051 9937 | Work: <clive@xxxxxxxxx>
Please reply to the Reply-To address, which is: <clive@xxxxxxxxxx>
.
- References:
- Results of the memswap() smackdown from the thread "Sorting" assignment
- From: spinoza1111
- Re: Results of the memswap() smackdown from the thread "Sorting" assignment
- From: spinoza1111
- Re: Results of the memswap() smackdown from the thread "Sorting" assignment
- From: spinoza1111
- Re: Results of the memswap() smackdown from the thread "Sorting" assignment
- From: Willem
- Re: Results of the memswap() smackdown from the thread "Sorting" assignment
- From: Malcolm McLean
- Re: Results of the memswap() smackdown from the thread "Sorting" assignment
- From: Richard Heathfield
- Re: Results of the memswap() smackdown from the thread "Sorting" assignment
- From: Malcolm McLean
- Results of the memswap() smackdown from the thread "Sorting" assignment
- Prev by Date: Re: how to align instructions?
- Next by Date: Re: "STL from the Ground Up"
- Previous by thread: Re: Results of the memswap() smackdown from the thread "Sorting" assignment
- Next by thread: Re: Results of the memswap() smackdown from the thread "Sorting" assignment
- Index(es):
Relevant Pages
|