Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!casbah.acns.nwu.edu!ftpbox!motsrd!motcid!mostek From: mostek@motcid.UUCP (Frank B. Mostek) Newsgroups: comp.lang.c Subject: Re: pointer->pointer problem Message-ID: <6147@beryl12.UUCP> Date: 5 Apr 91 22:26:15 GMT References: <1991Apr3.174058.13536@bnlux1.bnl.gov> Distribution: na Organization: Motorola Inc., Cellular Infrastructure Div., Arlington Heights, IL Lines: 35 reilly@bnlux1.bnl.gov (kevin reilly) writes: >main() >{ >char **outPt; >outPut = FUNC1(...); >FUNC2(outPut); >} >char **FUNC1(...) >{ >static char *lines[10]; ^^^^^^^^^^^^^^^ You have commited the dreaded C string memory allocation error. Your problem is analogous to the following: char *p; strcpy(p, "BLOW AWAY SOME MEMORY, HOPEFULLY YOUR OS HAS MEM PROTECTION"); You need to allocate space for each pointer. E.g. line[1] = malloc(strlen(str) + 1); /* Normally called strsave() */ strcpy(line[1], str); OR, you could declare a 2 dimensional array. (if you know in advance how big everything is going to be.) Hope this helps. -- ************************************************************ Frank Mostek uunet!motcid!amethyst!mostek Software Consultant (708)632-7191 ************************************************************