Path: utzoo!utgpu!news-server.csri.toronto.edu!rutgers!netnews.upenn.edu!cs.widener.edu!news.cs.indiana.edu!samsung!caen!hellgate.utah.edu!dog.ee.lbl.gov!elf.ee.lbl.gov!torek From: torek@elf.ee.lbl.gov (Chris Torek) Newsgroups: comp.lang.c Subject: Re: Question about pointer Message-ID: <10497@dog.ee.lbl.gov> Date: 2 Mar 91 00:45:36 GMT References: <2488@njitgw.njit.edu> Reply-To: torek@elf.ee.lbl.gov (Chris Torek) Distribution: usa Organization: Lawrence Berkeley Laboratory, Berkeley Lines: 27 X-Local-Date: Fri, 1 Mar 91 16:45:36 PST In article <2488@njitgw.njit.edu> yxz1684@hertz.njit.edu (Ying Zhu ee) writes: >The following is a small program from "Mastering C pointers" by Robert J. >Traister. [example deleted] ... Since the r[100] is an automatic variable, >after calling the "combine" the r[100] will be deallocated [and] p will >point to an unsafe place. Correct. If the example in this book appears exactly as shown in <2488@njitgw.njit.edu>, I would suggest either discarding the book entirely (reselling it merely pushes the bogus information on someone else) or---if this is atypical, and merely one mistake out of a great deal of correct code---advising the author and/or publisher, and marking the example in the book to note its error or repair it. (One `static' will repair this particular sample, for instance.) Note that the only excuse these days for buggy examples is when the publisher do their own re-typesetting, since book examples should be typeset by direct insertion of working code into the typesetting system. There are many C books available these days, and a large fraction of them are inexcusably bad. Do not trust any single source (except perhaps a copy of the ANSI C standard X3.159-1989). -- In-Real-Life: Chris Torek, Lawrence Berkeley Lab EE div (+1 415 486 5427) Berkeley, CA Domain: torek@ee.lbl.gov