Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!ames!oliveb!felix!dhw68k!arcturus!evil From: evil@arcturus.UUCP (Wade Guthrie) Newsgroups: comp.lang.c Subject: Re: modification of strings Summary: protected memory Message-ID: <3656@arcturus> Date: 10 Feb 89 16:45:18 GMT References: <7429@csli.STANFORD.EDU> <466@oglvee.UUCP> <11711@haddock.ima.isc.com> Organization: Rockwell International, Anaheim, CA Lines: 21 In article <11711@haddock.ima.isc.com>, karl@haddock.ima.isc.com (Karl Heuer) writes: > In article <466@oglvee.UUCP> norm@oglvee.UUCP (Norman Joseph) writes: > >[The previous example overflows,] but what if the code looked like this: > > char *blah = "meow\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"; > > strcpy( blah, "grr, snarl, hiss" ); [. . .] > This kludge is confusing and unportable. Don't use it. Just thought I might leap into the foray: One aspect of the portability issue is, unless I misremember, that the compiler may place string literals in protected memory (if that exists on your system) causing an exception and subsequent *BOMB* upon attempted modification. Wade Guthrie evil@arcturus.UUCP Rockwell International Anaheim, CA (Rockwell doesn't necessarily believe / stand by what I'm saying; how could they when *I* don't even know what I'm talking about???)