Bonkers
David Cantrell
david at cantrell.org.uk
Mon May 14 14:34:28 BST 2007
On Sun, May 13, 2007 at 09:35:22AM +0100, Andy Wardley wrote:
> It's also worth noting that this is Not Allowed:
>
> char *string = "this is a test",
> strcpy(*string, "new string");
>
> You shouldn't update static strings lest you crave a Bus Error
> or Segmentation Fault.
Obviously doing that when "new string" is longer than "this is a test"
is a no-no, but what's wrong with it in the specific example you gave?
> Caveat: I am not a C programmer (well, not that often)
Nor am I (that often).
Oh, I figgered out what's wrong with it. Memory allocated read-only for
paranoid reasons?
--
David Cantrell | A machine for turning tea into grumpiness
Longum iter est per praecepta, breve et efficax per exempla.
More information about the london.pm
mailing list