home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c
- Path: sparky!uunet!ocsmd!ted
- From: ted@ocsmd.ocs.com (Ted Scott)
- Subject: Re: character pointers in funtion calls
- Message-ID: <BzGu96.7sI@ocsmd.ocs.com>
- Sender: news@ocsmd.ocs.com
- Organization: Online Computer Systems, Inc.
- X-Newsreader: Tin 1.1 PL5
- References: <1992Dec18.021709.16972@thunder.mcrcim.mcgill.edu>
- Date: Fri, 18 Dec 1992 17:36:40 GMT
- Lines: 35
-
- der Mouse (mouse@thunder.mcrcim.mcgill.edu) wrote:
- : In article <BzD1w3.1z5@ocsmd.ocs.com>, ted@ocsmd.ocs.com I wrote:
- : > Step 1: Get a good C primer and look at the memory sections, then
- : > walk through the code you present here and see if you can find some
- : > of these problems:
- : Hm, I think you might do well to follow this advice yourself in a
- : couple of cases.
- Only a couple?!? My I *am* _starting_ to learn this dialect. I don't give
- advice I won't follow, doesn't mean I remember everything.
-
- :>: return (i); <- (and implicitly free the memory on the stack
- :> where i had a happy albiet brief life)
- :> returning the old value of i which may or may
- :> not be overwritten when printf uses the stack.
- :
- : No, no, no. It is correct that the storage allocated to the variable i
- : goes away when f returns. This *does not matter*, since no reference
- : to that storage survives. The return statement returns the value that
- : was stored there, not, as you seem to think, a pointer to the storage
- : in question.
- Yes, of course, must a been thinking of that other language.
- (a waist is a terrible thing to mind... or something).
-
- <At the white board: returns are by value, not by reference...>
-
- : That value is itself a pointer, but it points to a string
- : literal, which does *not* go away.
- And is usually read only storage.
-
- Thanks.
- --
-
- -Ted (I been a bad boy, Abbot) Scott
- tscott@ocsmd.ocs.com I was told that I'm a P.C. person:
- (301) 601-2252 Politically Challenged, that is.
-