## question on memory allocation for char strings ##

Roger Meunier roger at zuken.co.jp
Fri Jun 29 23:51:24 AEST 1990


In article <601 at babcock.cerc.wvu.wvnet.edu> siping at cathedral.cerc.wvu.wvnet.edu (Siping Liu) writes:

 >char *f2()
 >{
 >  char abc[100];
 >
 >  strcpy(abc, "12345");
 >
 >  return(abc);
 >}

If you want to use the return value from f2() safely, make abc storage
class static, not automatic.  No variable in f2()'s scope is safe
outside of f2() otherwise.

--
Roger Meunier @ Zuken, Inc.  Yokohama, Japan	(roger at zuken.co.jp)



More information about the Comp.lang.c mailing list