Sujet : Re: relearning C: why does an in-place change to a char* segfault?
De : mark (at) *nospam* qtrac.eu (Mark Summerfield)
Groupes : comp.lang.cDate : 01. Aug 2024, 09:54:23
Autres entêtes
Message-ID : <IoGcndEJ1Zmi0Db7nZ2dnZfqnPWdnZ2d@brightview.co.uk>
References : 1 2
User-Agent : Pan/0.154 (Izium; 517acf4)
On Thu, 1 Aug 2024 09:38:13 +0100, Richard Harnden wrote:
[snip]
text is pointing to "this is a test" - and that is stored in the program
binary and that's why can't modify it.
Change it to:
char text[] = "this is a test";
You can modify that, text gets it's own copy.
Thanks that works; & thanks for the explanation.