Scoping question in C
Henry Spencer
henry-lqW1N6Cllo0sV2N9l4h3zg at public.gmane.org
Fri Jun 10 02:49:04 UTC 2005
On Thu, 9 Jun 2005 pking123-rieW9WUcm8FFJ04o6PK0Fg at public.gmane.org wrote:
> 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).
Show us your code, please -- all of it.
The construct being asked about is legitimate standard C and *will* work
on any conforming implementation. I speak as someone who participated in
developing both versions (C89 and C99) of the C standard, and a member of
the Standards Council of Canada working group that sorts out how Canada
should vote at ISO on new C-standards issues.
Not only will it work on any conforming implementation, it'll even work on
GCC. :-) I tried it; it works. What I wrote was:
#include <stdio.h>
char *x;
int
func()
{
x = "something";
return (1);
}
main() {
func();
printf("%s\n", x);
exit(0);
}
It prints "something" in all of the C implementations I've got handy.
Henry Spencer
henry-lqW1N6Cllo0sV2N9l4h3zg at public.gmane.org
--
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