string literals
Robert Fraser
fraserofthenight at gmail.com
Sun Jan 27 22:44:50 PST 2008
Milke Wey wrote:
> On Sat, 2008-01-26 at 15:26 -0500, bearophile wrote:
>> Milke Wey:
>>> On linux you would get an nice Segfault when running that code.
>> Ah, thank you then. I have thought that's true only for string literals assigned to static arrays:
>>
>> void main() {
>> char[3] str = "abc";
>> str[0] = 'b';
>> }
>>
>> Bye,
>> bearophile
>
> I don't know why but it actually works when using a static array.
>
On a UNIX system or a Windows system? It should work fine on Windows
anyway. Also, the static array declaration may say to the compiler
"allocate this on the stack"... not sure; I don't think that's speced.
More information about the Digitalmars-d-learn
mailing list