Hi,
char* string = "Test";
char* p_test = string;printf("%c\n", string[2]);
printf("%c\n", p_test[2]);//Weder das...
string[2]='x';
//noch das funktioniert...
p_test[2]='x';
...es führt beides zu einem Segmentation Fault. Wie kann ich mir das erklären?
ich vermute, dass der konstante String "Test" als Bytefolge 54 65 73 74 00 im Codesegment abgelegt wird, das durch den daraus resultierenden Prozess nicht beschrieben werden darf.
Seit wann ist es nicht erlaubt, Zeichen in einem Array zu überschreiben?
Kommt drauf an, in welchen Segment sie liegen (was der zuständige Descriptor für Berechtigungen angibt).
Ciao,
Martin
--
Success should be measured not so much by the position that one has reached in life,
but by the obstacles one has overcome while trying to succeed.
Success should be measured not so much by the position that one has reached in life,
but by the obstacles one has overcome while trying to succeed.