Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
| From | Keith Thompson <kst-u@mib.org> |
|---|---|
| Newsgroups | comp.lang.c |
| Subject | Re: Array of Integers ? |
| Date | 2011-11-09 19:34 -0800 |
| Organization | None to speak of |
| Message-ID | <lnaa84abvm.fsf@nuthaus.mib.org> (permalink) |
| References | (2 earlier) <37c51614-8e33-47b1-a5e6-9e3e6fdcb401@o15g2000vbo.googlegroups.com> <j9be9t$iag$1@reader1.panix.com> <j9bhk9$jh8$1@dont-email.me> <lnobwmcmkr.fsf@nuthaus.mib.org> <string-literal-20111110031330@ram.dialup.fu-berlin.de> |
ram@zedat.fu-berlin.de (Stefan Ram) writes:
> Keith Thompson <kst-u@mib.org> writes:
>>Correction: The behavior of a program that attempts to modify a
>>string literal is undefined.
>
> A string literal is part of the source code.
>
> The source code usually is not there when a program is running.
[...]
Yes, I was using a verbal shorthand. (And I've made enough similar
criticisms that it's a fair point.)
A string literal in source code corresponds to an array with static
storage duration that exists during program execution (C99 6.4.5).
The behavior of a program that attempts to modify that array is
undefined.
An example:
"hello"[0] = 'H';
A more realistic example:
void foo(char *s) { s[0] = 'h'; }
...
foo("hello");
--
Keith Thompson (The_Other_Keith) kst-u@mib.org <http://www.ghoti.net/~kst>
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
Back to comp.lang.c | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Array of Integers ? arnuld <sunrise@invalid.address> - 2011-11-08 07:51 +0000
Re: Array of Integers ? Ike Naar <ike@iceland.freeshell.org> - 2011-11-08 08:11 +0000
Re: Array of Integers ? jacob navia <jacob@spamsink.net> - 2011-11-08 09:14 +0100
Re: Array of Integers ? Nick Keighley <nick_keighley_nospam@hotmail.com> - 2011-11-08 00:23 -0800
Re: Array of Integers ? pete <pfiland@mindspring.com> - 2011-11-08 04:07 -0500
Re: Array of Integers ? tom st denis <tom@iahu.ca> - 2011-11-08 06:23 -0800
Re: Array of Integers ? "Scott Fluhrer" <sfluhrer@ix.netcom.com> - 2011-11-08 10:08 -0500
Re: Array of Integers ? Noob <root@127.0.0.1> - 2011-11-08 16:25 +0100
Re: Array of Integers ? bks@panix.com (Bradley K. Sherman) - 2011-11-08 15:39 +0000
Re: Array of Integers ? Keith Thompson <kst-u@mib.org> - 2011-11-08 13:48 -0800
Re: Array of Integers ? Keith Thompson <kst-u@mib.org> - 2011-11-09 19:34 -0800
Re: Array of Integers ? Nick Keighley <nick_keighley_nospam@hotmail.com> - 2011-11-08 06:59 -0800
Re: Array of Integers ? jacob navia <jacob@spamsink.net> - 2011-11-08 22:48 +0100
Re: Array of Integers ? Chad <cdalten@gmail.com> - 2011-11-08 07:12 -0800
Re: Array of Integers ? pete <pfiland@mindspring.com> - 2011-11-08 11:49 -0500
Re: Array of Integers ? James Kuyper <jameskuyper@verizon.net> - 2011-11-08 12:13 -0500
Re: Array of Integers ? Ben Bacarisse <ben.usenet@bsb.me.uk> - 2011-11-08 21:45 +0000
Re: Array of Integers ? James Kuyper <jameskuyper@verizon.net> - 2011-11-08 16:48 -0500
Re: Array of Integers ? Keith Thompson <kst-u@mib.org> - 2011-11-08 14:25 -0800
Re: Array of Integers ? Ben Bacarisse <ben.usenet@bsb.me.uk> - 2011-11-08 22:42 +0000
Re: Array of Integers ? Phil Carmody <thefatphil_demunged@yahoo.co.uk> - 2011-11-10 12:01 +0200
Re: Array of Integers ? Keith Thompson <kst-u@mib.org> - 2011-11-10 03:14 -0800
Re: Array of Integers ? Phil Carmody <thefatphil_demunged@yahoo.co.uk> - 2011-11-10 17:41 +0200
Re: Array of Integers ? Ben Bacarisse <ben.usenet@bsb.me.uk> - 2011-11-10 16:44 +0000
Re: Array of Integers ? Keith Thompson <kst-u@mib.org> - 2011-11-10 10:59 -0800
Re: Array of Integers ? Phil Carmody <thefatphil_demunged@yahoo.co.uk> - 2011-11-11 17:49 +0200
Re: Array of Integers ? Keith Thompson <kst-u@mib.org> - 2011-11-08 14:00 -0800
Re: Array of Integers ? Ben Bacarisse <ben.usenet@bsb.me.uk> - 2011-11-09 00:57 +0000
Re: Array of Integers ? pete <pfiland@mindspring.com> - 2011-11-09 00:05 -0500
Re: Array of Integers ? Ben Bacarisse <ben.usenet@bsb.me.uk> - 2011-11-09 11:06 +0000
Re: Array of Integers ? Keith Thompson <kst-u@mib.org> - 2011-11-09 13:36 -0800
Re: Array of Integers ? Tim Rentsch <txr@alumni.caltech.edu> - 2012-01-25 00:45 -0800
Re: Array of Integers ? Keith Thompson <kst-u@mib.org> - 2012-01-25 02:56 -0800
Re: Array of Integers ? pete <pfiland@mindspring.com> - 2011-11-09 18:34 -0500
Re: Array of Integers ? Ben Bacarisse <ben.usenet@bsb.me.uk> - 2011-11-10 00:57 +0000
Re: Array of Integers ? Keith Thompson <kst-u@mib.org> - 2011-11-08 22:14 -0800
Re: Array of Integers ? Tim Rentsch <txr@alumni.caltech.edu> - 2012-01-25 01:46 -0800
Re: Array of Integers ? Malcolm McLean <malcolm.mclean5@btinternet.com> - 2011-11-08 01:39 -0800
Re: Array of Integers ? Keith Thompson <kst-u@mib.org> - 2011-11-08 14:05 -0800
Re: Array of Integers ? James Kuyper <jameskuyper@verizon.net> - 2011-11-08 06:19 -0500
csiph-web