Scoping question in C

William Park opengeometry-FFYn/CNdgSA at public.gmane.org
Fri Jun 10 02:46:59 UTC 2005


On Thu, Jun 09, 2005 at 08:36:16PM -0400, pking123-rieW9WUcm8FFJ04o6PK0Fg at public.gmane.org wrote:
> > I have question regarding scope of static string inside C function.
> > Suppose I have
> > 
> >     char *x;
> > 
> >     int func ()
> >     {
> >  x = "something";
> >  return (1);
> >     }
> > 
> 
> You can test this out yourself with this code, defining a main() and 
> printf'ing the result. On Cygwin, I get nothing (2 carriage returns).

I did try it, and got what Henry and others said.  But, I just wanted to
make sure that data access is legal.  Because, sometimes, I could access
data pointed to by a dangling pointer for a while, before I get
segfault.

-- 
William Park <opengeometry-FFYn/CNdgSA at public.gmane.org>, Toronto, Canada
ThinFlash: Linux thin-client on USB key (flash) drive
	   http://home.eol.ca/~parkw/thinflash.html
--
The Toronto Linux Users Group.      Meetings: http://tlug.ss.org
TLUG requests: Linux topics, No HTML, wrap text below 80 columns
How to UNSUBSCRIBE: http://tlug.ss.org/subscribe.shtml





More information about the Legacy mailing list