Mail Archives: djgpp/1997/10/15/00:46:35
Guan Foo Wah wrote:
snip:
>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.
Guan Foo Wah,
I can't be sure without experimenting some but it sounds like the compiler
is optimizing duplicate strings. You will find this is an option with Turbo
C++ 3.0 (Options / Compiler / Code Generation). For now all I can suggest is
to declare your arrays, and then to set there contents later in the code
(inside main?) and see if that helps. Hopefully someone else may come through
with how to disable the optimization (if that's the case) or with another
idea.
Sincerely,
Br5an AT aol DOT com
- Raw text -