string literals

Saaa empty at needmail.com
Fri Jan 25 18:16:55 PST 2008


from the 1.0 documentation:char[] str;
char[] str1 = "abc";
str[0] = 'b';        // error, "abc" is read only, may crash Is this example 
correct?
> Saaa:
>
>> If you load a file into a char[][], will the file be stored in the code
>> segment?
>
> Nope.
>
>
>> But shouldn't there be an way (per variable) to force the compiler to not
>> store it like that?
>
> In practice, there is. In D 1.x string literals are, dynamic ones aren't.
>
>
>> I know this, although it just says it creates a dynamic array. How do you
>> know that the .dup dynamic array is not read-only.
>
> In D.1.x dyn arrays are mutable.
>
> Bye,
> bearophile 




More information about the Digitalmars-d-learn mailing list