Message-ID: <19971013092045.160.rocketmail@send1.rocketmail.com> Date: Mon, 13 Oct 1997 02:20:45 -0700 (PDT) From: Guan Foo Wah Subject: Is this a bug ??? or feature ?? To: djgpp AT delorie DOT com MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Precedence: bulk Check the program out below //starts here------------------------------------------------------- #include char *num[] = { "one", //line 4 "one", //line 5 :- this string exactly the same as line 4 "three", "four" }; char *id[] = { "ten", "two", "one", //line 13 :- exactly same as line 4 and 5 "F16", "DJGPP" }; void main (void) { //prints the address of the 3 variables printf ("Address : %p %p %p %p\n", num[0], num[1], id[2]); //prints the value of the 3 variables before modifying printf ("Value before modifying : %s %s %s\n", num[0], num[1], id[2]); //modify one of the 3 variables num[0][0] = 'f'; //prints the value of the 3 variables after modifying printf ("Value after modifying : %s %s %s\n", num[0], num[1], id[2]); } //ends here----------------------------------------------------------- This is the output compiled on the DJGPP compiler (using BNU281B.ZIP) Address : 155b 155b 155b Value before modifying : one one one Value after modifying : fne fne fne and this is the output compiled on the TURBO C v3.0 Address : 00BC 00C0 00D7 Value before modifying : one one one Value after modifying : fne one one From the program output compiled on the DJGPP compiler, it seems that num[0], num[1] and id[2] share the same location memory. Why is this so ?? When line 4 in the code which is "one" is replaced with "one ", the output will change to the one below. Address : 155f 155b 155b Value before modifying : one one one Value after modifying : fne one one This time, num[1], and id[2] share the same memory location. Can anyone please tell me how to make those three variables not to share the same memory location ?? This is important in my project which I am currently working on. _____________________________________________________________________ Sent by RocketMail. Get your free e-mail at http://www.rocketmail.com