[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
RE: Varför segmenteringsfel?
From: |
Vincent Penquerc'h |
Subject: |
RE: Varför segmenteringsfel? |
Date: |
Fri, 13 Jul 2001 14:24:20 +0100 |
> Thanks! I just figured out that it works with char a[] = "xy". But I will
> test -fwriteable-strings. I didn't know there was such an option. Thanks.
a* is a pointer, which points to a read only xopy of the string.
a[] is an array, with allocated space (writeable) for your string, which
is placed in a writeable section. If you do:
char *a="FOOBAR";
char *b="FOOBAR";
then one copy only of FOOBAR will be emitted (though this is not dictated
by the standard, just a common optimization), but if you do:
char a[]="FOOBAR";
char b[]="FOOBAR";
then two distinct modifiable sgtrings will be emitted. Your responsibility
to know whhat to use, depending on whwther you want to afford the space.
--
Lyrian