This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

string constants



Hi,
  I have a doubt regarding string constants.
please see the following example.

   char *p = "megcc";

  for (i = 0; i < strlen (p); i++)
      p[i] =  'a';
  when I run this program it will give segmentation
fault.  
  If I compile the program using -fwritable-string
 it works fine.
   But  if I make 

  p as static char *p, it should work (guess).
 but actually it is not. It still gives segmentation
fault. Could you help me with this.

  regards

V.Brahmaiah






__________________________________________________
Do You Yahoo!?
Yahoo! Shopping - Thousands of Stores. Millions of Products.
http://shopping.yahoo.com/

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]