Archives
D Programming
DD.gnu digitalmars.D digitalmars.D.bugs digitalmars.D.dtl digitalmars.D.dwt digitalmars.D.announce digitalmars.D.learn digitalmars.D.debugger C/C++ Programming
c++c++.announce c++.atl c++.beta c++.chat c++.command-line c++.dos c++.dos.16-bits c++.dos.32-bits c++.idde c++.mfc c++.rtl c++.stl c++.stl.hp c++.stl.port c++.stl.sgi c++.stlsoft c++.windows c++.windows.16-bits c++.windows.32-bits c++.wxwindows digitalmars.empire digitalmars.DMDScript |
c++ - Odd behavior in toy program
Hello group, I just downloaded the Digital Mars C/C++ compiler and was playing around with the piece of code shown at the end of this post. When I compile and run said code, I get the following output: dog = 8, dog_p points to 7 However, when I uncomment the printf("hello world") line I get the output I expect: dog = 7, dog_p points to 7 I'm confused as to what is going on. Anyone care to enlighten me? Thanks! Vic ------------------------------------------------------- #include <stdio.h> main() { const int dog = 8; int *dog_p = (int *)&dog; *dog_p = 7; //printf("hello world!\n"); printf("dog = %d, dog_p points to %d\n", dog, *dog_p); } ------------------------------------------------------- Aug 24 2005
|