home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #27 / NN_1992_27.iso / spool / comp / lang / c / 16893 < prev    next >
Encoding:
Text File  |  1992-11-20  |  1.5 KB  |  53 lines

  1. Newsgroups: comp.lang.c
  2. Path: sparky!uunet!ocsmd!ted
  3. From: ted@ocsmd.ocs.com (Ted Scott)
  4. Subject: Re: Where are literals stored?
  5. Message-ID: <By0vzy.4Ly@ocsmd.ocs.com>
  6. Sender: news@ocsmd.ocs.com
  7. Organization: Online Computer Systems, Inc.  Germantown, Md., 20874
  8. X-Newsreader: Tin 1.1 PL5
  9. References: <27542@dog.ee.lbl.gov>
  10. Date: Fri, 20 Nov 1992 16:19:08 GMT
  11. Lines: 40
  12.  
  13. Chris Torek (torek@horse.ee.lbl.gov) wrote:
  14. : In article <1992Nov18.233739.2335@den.mmc.com>
  15. : richard@crowded-house.den.mmc.com (Richard Armstrong) writes:
  16. : >For instance, is the string a stored in the same place in the following
  17. : >two declarations?:
  18. : >static char a[]="ABC"
  19. : >funca()
  20. : >{
  21. : >char a[]="ABC";
  22. : >}
  23. : Neither of these is in fact a `string literal': in both cases the
  24. : quoted strings are initializers for objects.  String literals are
  25. : formed from quoted strings that appear in a value context, e.g.,
  26. :     char *p, *q;
  27. :     p = "ABC";
  28. :     q = "ABC";
  29. :
  30. :     /* it is unspecified whether p == q */
  31. : Distinct objects, however, always compare unequal, thus the following
  32. : strictly conformant program must print `0':
  33. Ok, *I'm* confused here. Does this mean that if I do something like:
  34.  
  35.  *p[1] = ' '; 
  36.  
  37. q will now point to "A C" ??
  38.  or will the above assignment yield a SEGV? 
  39.  or what? (I know probably what :)
  40.  
  41. To carry this on further, what if p and q are in different scope, but the 
  42. same source file?
  43.  
  44.  
  45. --
  46.  
  47. -Ted Scott          
  48. tscott@ocsmd.ocs.com           I was told that I'm a P.C. person:
  49. (301) 601-2252                               Politically Challenged, that is.
  50.