Path: utzoo!news-server.csri.toronto.edu!cs.utexas.edu!wuarchive!zaphod.mps.ohio-state.edu!magnus.ircc.ohio-state.edu!tut.cis.ohio-state.edu!ucbvax!dog.ee.lbl.gov!nosc!humu!pilikia!art From: art@pilikia.pegasus.com (Art Neilson) Newsgroups: comp.lang.c Subject: Re: Is this ok?? Keywords: pointer initialization Message-ID: <1991Mar10.040429.29309@pilikia.pegasus.com> Date: 10 Mar 91 04:04:29 GMT References: <1991Mar08.191107.23161@pilikia.pegasus.com> <1991Mar9.073231.1364@athena.mit.edu> Distribution: comp Organization: Pilikia, Honolulu Lines: 35 In article <1991Mar9.073231.1364@athena.mit.edu> scs@adam.mit.edu writes: >In article <1991Mar08.191107.23161@pilikia.pegasus.com> art@pilikia.pegasus.com (Art Neilson) writes: >>In article davis@pacific.mps.ohio-state.edu (John E. Davis) writes: >The code posted by John Davis was correct, although it contained >several (perfectly legal) pointers to pointers which apparently >confused both a VMS compiler (thus John's original question) and >Arthur Neilson (thus these irrelevant criticisms). The code >passes lint -hbxa with flying colors (i.e. no complaints about >argument mismatches) and runs correctly under any number of >compilers. Guess I deserve a bit of public chastisement for my criticisms. I still don't get why the string assignment *s = "Hello\n"; in fm2() is ok. Raymond Chen sent me an email stating that storage for "Hello\n" was allocated as static anonymous readonly by the compiler. I had always thought that the rvalue in a pointer assignment had to be an address. The usual way I do assignments of this nature is to either explicitly declare an array large enough to hold the string or malloc the storage and move the data there, or assign the pointer globally (outside of main) like: char *s = "Hello\n"; /* aggregate initializations out here */ main() { John's program does compile and run on my system ;^) (sheepish grin) so it must be ok. Since the assignment is ok, how large a string can be assigned in this manner ? Does the constant go in .data or .bss ?? -- Arthur W. Neilson III | INET: art@pilikia.pegasus.com Bank of Hawaii Tech Support | UUCP: uunet!ucsd!nosc!pilikia!art