Path: utzoo!utgpu!water!watmath!clyde!att!whuts!homxb!mhuxu!m10ux!rgr From: rgr@m10ux.UUCP (Duke Robillard) Newsgroups: comp.lang.c Subject: Re: Are strings local? Keywords: Help! Message-ID: <652@m10ux.UUCP> Date: 3 Aug 88 18:03:40 GMT References: <644@m10ux.UUCP> <12791@mimsy.UUCP> Reply-To: rgr@m10ux.UUCP (Duke Robillard) Organization: AT&T Bell Labs, Murray Hill Lines: 29 In article <12791@mimsy.UUCP> chris@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@m10ux.ATT.COM