Scoping question in C

Peter plp-ysDPMY98cNQDDBjDh4tngg at public.gmane.org
Fri Jun 10 18:58:24 UTC 2005



>> But, if the static string lives for the duration of the program, then
>> pointer to it should always be valid, no?  Eg.
>> 	char *y;
>> 	y = "something inside";
>> 	return (y);
>> Here, 'y' (or, what the function returns) should be valid for entire
>> program.

The point is that it returns the *value* of y and not y proper. The 
value of y is the address of the static string so it works.

Peter
--
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