Newsgroups: comp.lang.c Path: utzoo!henry From: henry@utzoo.uucp (Henry Spencer) Subject: Re: char *Foo VS. char Bar[] Message-ID: <1989Apr14.161325.28114@utzoo.uucp> Organization: U of Toronto Zoology References: <19636@iuvax.cs.indiana.edu> Date: Fri, 14 Apr 89 16:13:25 GMT In article <19636@iuvax.cs.indiana.edu> bobmon@iuvax.cs.indiana.edu (RAMontante) writes: > char *foo = " "; > ... > sprintf(foo,"xxxx"); > >Using gcc on a VAX8650/Ultrix, the sprintf causes a bus error. The standard >cc compiler produced code that "worked"... Old C guaranteed that string constants were writeable storage. ANSI C says that the compiler is entitled to make them read-only if it wants. Many people have felt all along that writing into string constants was bad practice. -- Welcome to Mars! Your | Henry Spencer at U of Toronto Zoology passport and visa, comrade? | uunet!attcan!utzoo!henry henry@zoo.toronto.edu