Path: utzoo!mnetor!uunet!husc6!purdue!umd5!mimsy!chris From: chris@mimsy.UUCP (Chris Torek) Newsgroups: comp.lang.c Subject: Re: VMS pointer problems continue. Message-ID: <10796@mimsy.UUCP> Date: 25 Mar 88 19:04:21 GMT References: <12602@brl-adm.ARPA> <812@cresswell.quintus.UUCP> <1494@se-sd.sandiego.NCR.COM> Organization: U of Maryland, Dept. of Computer Science, Coll. Pk., MD 20742 Lines: 38 In article <1494@se-sd.sandiego.NCR.COM> rns@se-sd.sandiego.NCR.COM (Rick Schubert) writes: >Although Richard A. O'Keefe has pointed out the primary error in [ char *wr(a) int a; { char b = "Arf!"; return (b); } /* should be char *b = ... */ /* (this error should cause at least a warning at compile time) */ >] ... there is another error, although most implementations of C >will handle it in the intended way (notice that I did not say "the >right way"). The string pointed to by b ("Arf!") should be considered >local to wr(); the compiler is free to allocate it on the stack . . . . This is not the case. String constants have type `array N of char' and static storage duration. These are the only anonymous aggregate types that exist in C. Writing char *wr() { return ("Arf!"); } is essentially equivlaent to writing char *wr() { static char _not_named_[5] = { 'A', 'r', 'f', '!', '\0' }; return (_not_named_); } >I submitted the above, but inews asked for more; rather than just filling >the required space, I'll try to make efficient use of it by giving >one example of <> behavior. [deleted] Well, at least *someone* had the sense to fill with something other than `filler' lines. You can also change the quote character to something other than `>'. E.g., in vi, type :%s/^>/-/ -- In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 7163) Domain: chris@mimsy.umd.edu Path: uunet!mimsy!chris