Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!swrinde!cs.utexas.edu!sun-barr!newstop!sun!amdcad!dgcad!dg-rtp!sheol!throopw From: throopw@sheol.UUCP (Wayne Throop) Newsgroups: comp.lang.c Subject: Re: pointer->pointer problem Summary: uninitialized pointers (among other problems) Message-ID: <1638@sheol.UUCP> Date: 8 Apr 91 00:25:56 GMT References: <1991Apr3.174058.13536@bnlux1.bnl.gov> Lines: 20 > reilly@bnlux1.bnl.gov (kevin reilly) > [...whitespace squeezed for brevity...] > main() { char **outPt; outPut = FUNC1(...); FUNC2(outPut); } > char **FUNC1(...) { static char *lines[10]; /* do stuff */ return > &lines[0]; } > void FUNC2(char **inPut) { /* If I manipulate the strings pointed to by > inPut in this function it seems other strings are also effected. > Why is this? */ } *What* strings pointed to by inPut? These pointers have never been initialized to point to anything. (In fact, being static, they've been initialized to point to *no*thing, and since nil pointers often in "reality" point to the same non-place, this is likely the cause of the aliasing observed.) And while we're at it, isn't terribly wise to redeclare function return types (from (int) to (char**) and from (int) to (void)). It is likewise unwise to fail to return a value from "main". -- Wayne Throop ...!mcnc!dg-rtp!sheol!throopw