Mail Archives: cygwin/2000/03/12/10:53:33
------=_NextPart_000_70eeadd3_27587b9c$33efc487
Content-Type: text/plain; format=flowed
First of all, thanks for you kindy answer ...
I have the last question. I rewrite the program as follow:
line 1: #include <iostream>
line 2: void main()
line 3: { const int size=10;
line 4: int A[size];
line 5: int *X=NULL, i;
line 6: for (i=0;i<size;i++) A[i]=i;
line 7: cout<<A[0]<<" "<<&A<<" "<<&A[0]<<endl;
line 8: X=A;
line 9: cout<<A[0]<<" "<<&A<<" "<<&A[0]<<endl
line 10: <<*X<<endl
line 11: <<*X+5<<endl
line 12: <<*X<<" "<<A[0]<<endl
line 13: <<5+X[0]<<endl
line 14: <<( X[0]==0 ? "X[0]=0" : "X[0]!=0")<<endl;
line 15: cout<<++X[0]<<endl; //the change here
line 16: }
and executing it gives output:
$./a.out
0 0x259fd7c 0x259fd7c
0 0x259fd7c 0x259fd7c
0
5
0 0
5
X[0]=0
1
Obviously, it gives the correct answer (line 7 = line 9). I
just wonder what is the different between the original code (using
a single "cout", see test.cc attached) and new code (use another
cout to print ++X[0], above).
Actually, I tried the original program many time on my PC
running Cygnus. To remove external factor, I close all other
program after a re-boot. But the result is still wrong (see last e-mail).
Then, to test my program is correct or not, I tried it on a
UNIX SVR with gcc compiler. Then the program works properly.
So, I just conclude there is some wrong with the cygwin, or
not as good as gcc. Thanks.
______________________________________________________
Get Your Private, Free Email at http://www.hotmail.com
------=_NextPart_000_70eeadd3_27587b9c$33efc487
Content-Type: application/octet-stream; name="test.cc"
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename="test.cc"
I2luY2x1ZGUgPHN0ZGlvLmg+DQojaW5jbHVkZSA8aW9zdHJlYW0uaD4NCg0K
dm9pZCBtYWluKCkNCnsgY29uc3QgaW50IHNpemU9MTA7DQogIGludCBBW3Np
emVdOw0KICBpbnQgKlg9TlVMTCwgaTsNCiAgDQogIGZvciAoaT0wO2k8c2l6
ZTtpKyspIEFbaV09aTsNCiAgY291dDw8QVswXTw8IiAiPDwmQTw8IiAiPDwm
QVswXTw8ZW5kbDsNCiAgWD1BOw0KICBjb3V0PDxBWzBdPDwiICI8PCZBPDwi
ICI8PCZBWzBdPDxlbmRsDQogICAgICA8PCpYPDxlbmRsDQogICAgICA8PCpY
KzU8PGVuZGwNCiAgICAgIDw8Klg8PCIgIjw8QVswXTw8ZW5kbA0KICAgICAg
PDw1K1hbMF08PGVuZGwNCiAgICAgIDw8KCBYWzBdPT0wID8gIlhbMF09MCIg
OiAiWFswXSE9MCIpPDxlbmRsDQogICAgICA8PCsrWFswXTw8ZW5kbDsNCn0N
Cg==
------=_NextPart_000_70eeadd3_27587b9c$33efc487
Content-Type: text/plain; charset=us-ascii
--
Want to unsubscribe from this list?
Send a message to cygwin-unsubscribe AT sourceware DOT cygnus DOT com
------=_NextPart_000_70eeadd3_27587b9c$33efc487--
- Raw text -