Message-Id: Comments: Authenticated sender is From: "Salvador Eduardo Tropea (SET)" Organization: INTI To: Guan Foo Wah , djgpp AT delorie DOT com Date: Mon, 13 Oct 1997 15:49:48 +0000 MIME-Version: 1.0 Content-type: text/plain; charset=US-ASCII Content-transfer-encoding: 7BIT Subject: Re: Is this a bug ??? or feature ?? Precedence: bulk Guan Foo Wah wrote: [Sniped code making not so good things] > > 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 That's because they are CONSTANTS so the compiler suposse you'll never modify it. As you already got as reply you can change it. These variables are normally in the code! > 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 Just because you don't turned on the optimize for size switchs ;-) There are one called merge strings or similar. > >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 ?? To avoid multiple copies of the same. You are declaring: char *XXX=constant; And I guess you want to make: char XXX[nn]=__initializer__; The first can be modified making: XXX=another pointer But not writing on it! > 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. Use arrays, that what you want, not pointers. SET ------------------------------------ 0 -------------------------------- Visit my home page: http://www.geocities.com/SiliconValley/Vista/6552/ Salvador Eduardo Tropea (SET). (Electronics Engineer) Alternative e-mail: set-sot AT usa DOT net - ICQ: 2951574 Address: Curapaligue 2124, Caseros, 3 de Febrero Buenos Aires, (1678), ARGENTINA TE: +(541) 759 0013