pointer->pointer problem

Roy Johnson rjohnson at shell.com
Sat Apr 6 01:52:01 AEST 1991


In article <1991Apr3.174058.13536 at bnlux1.bnl.gov> reilly at bnlux1.bnl.gov (kevin reilly) writes:

>char **FUNC1(...)
>{
>static char *lines[10];
>/* do stuff */
>return &lines[0];
>}

I just realized that lines is static, so it *should* all be initialized
to zero (NULL) pointers; give us more information on what you are doing
with lines.  If you are assigning it like

lines[4]=another_string;

then any changes you make to lines[4] will of course change
another_string, and what you would probably want to do is allocate
space for lines[4] (as in my last response) and
 strcpy(lines[4], another_string);

--
======= !{sun,psuvax1,bcm,rice,decwrl,cs.utexas.edu}!shell!rjohnson =======
Feel free to correct me, but don't preface your correction with "BZZT!"
Roy Johnson, Shell Development Company



More information about the Comp.lang.c mailing list