home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.std.c
- Path: sparky!uunet!haven.umd.edu!decuac!pa.dec.com!nntpd2.cxo.dec.com!nntpd.lkg.dec.com!jit345.bad.jit.dec.com!diamond
- From: diamond@jit345.bad.jit.dec.com (Norman Diamond)
- Subject: Re: Memory Usage by C
- Message-ID: <1992Nov20.020950.15516@nntpd.lkg.dec.com>
- Sender: usenet@nntpd.lkg.dec.com (USENET News System)
- Reply-To: diamond@jit.dec.com (Norman Diamond)
- Organization: Digital Equipment Corporation Japan , Tokyo
- References: <1992Nov19.190526.26770@den.mmc.com>
- Date: Fri, 20 Nov 1992 02:09:50 GMT
- Lines: 38
-
- In article <1992Nov19.190526.26770@den.mmc.com> richard@crowded-house.den.mmc.com (Richard Armstrong) writes:
- >Are literals always stored in the same location in memory?
-
- The standard says that identical string literals need not be distinct.
- In some implementations they might go in the same location; in other
- implementations they might not. (It is not clear if partly identical string
- literals that could meaningfully overlap are also allowed to do so or not.)
-
- >(IBM-PC,Borland)
-
- Ask Borland. (The standard does not require them to answer; it doesn't
- say that this decision is implementation-defined. But you can always ask.)
-
- >For instance, is the string a stored in the same place in the following
- >two declarations?:
- >static char *a[]="ABC";
- >funca()
- >{
- >char *a[]="ABC";
- >}
-
- You cannot have two functions named funca() in the same source file, so
- I deleted the first one (which had nothing between the braces). I also
- added a semicolon to the end of the first line.
-
- In the first declaration, a is a static array. When the declaration is
- completed, the array size is determined to be 1. a[0] is a pointer-to-char,
- initially pointing to the first character in an array of 4 characters (A, B,
- C, and null character). This nameless array of 4 characters is static.
-
- In the later declaration, a is an automatic array. This a cannot go in the
- same place as the first a, the static array. This a[0] might initially
- point to the same static array of 4 characters that the first a[0] pointed
- to, or else to a different static array of 4 characters.
- --
- Norman Diamond diamond@jit081.enet.dec.com
- If this were the company's opinion, I wouldn't be allowed to post it.
- "It's been a lovely recession."
-