Afficher un message
Vieux 16/10/2007, 20h20   #3
$)CHarald van D)&k
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: constant string doubt

On Tue, 16 Oct 2007 19:14:07 +0000, Default User wrote:
> $)CHarald van D)&k wrote:
>
>> On Tue, 16 Oct 2007 12:03:43 -0500, Jack Klein wrote:
>> > By definition in the C standard, the type of a string literal like
>> > "abcdefgh" in the above program is array of char, and NOT array of
>> > const char. "abcdefgh" is not constant data in C.

>>
>> It is not const-qualified, but it is constant.

>
> It may or may not be. It is undefined behavior to attempt to modify the
> contents of a string literal.


It's constant in that its value isn't allowed to change without a
specific action by the program, and that all such actions by the program
are not allowed by the language. If you perform such an action anyway,
then sure, it's possible for its value to change, just like it's possible
for the value of a const-qualified object to change.
  Réponse avec citation
 
Page generated in 0,04431 seconds with 9 queries