Are strings local?
Duke Robillard
rgr at m10ux.UUCP
Thu Aug 4 04:03:40 AEST 1988
In article <12791 at mimsy.UUCP> chris at mimsy.UUCP (Chris Torek) writes...
...an explaination of my string dilemma. Thanks to Chris and everyone
else who helped me out.
During my search about this locality of statics business, I discovered
a pretty bizarre thing about strings. I dunno if it's just my System
V compiler or what, but you can write to strings (since they're just
static arrays of characters?) Like:
main()
{
char *p;
p= "abc";
p[2]= 'd';
printf("%s\n", p); /* this will print "abd\n" */
/* or, if you'd like to be even more obscure... */
(p= "def")[2]= 'x';
printf("%s\n", p); /* this will print "abx\n" */
}
Pretty weird, huh?
--
+------
| Duke Robillard
| AT&T Bell Labs {backbone!}att!m10ux!rgr
| Murray Hill, NJ rgr at m10ux.ATT.COM
More information about the Comp.lang.c
mailing list