modification of strings

Wade Guthrie evil at arcturus.UUCP
Sat Feb 11 02:45:18 AEST 1989


In article <11711 at haddock.ima.isc.com>, karl at haddock.ima.isc.com (Karl Heuer) writes:
> In article <466 at oglvee.UUCP> norm at 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 at 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???)



More information about the Comp.lang.c mailing list