Both the outputs are correct according to the compiler.

One executes the cout in left to right and another compiler will execute in 
right to left.



Thanks & Regards,

 Vijaya Rama Raju
________________________________
From: [email protected] [mailto:[email protected]] On Behalf Of Asad 
Abbas
Sent: Sunday, January 31, 2010 11:38 AM
To: [email protected]
Cc: [email protected]
Subject: [c-prog] Which compiler is wrong...?



[mod-- This is a FAQ:
<http://www.parashift.com/c++-faq-lite/misc-technical-issues.html#faq-39.15> -- 
mod PN]

Hi all....

consider the following code

 int arr[]={1,2,3,4,5};
 int* ptr=arr;
 cout<<++*ptr<<*ptr++<<(*ptr)++<<*++ptr<<++*ptr++<<endl;

Output on DEV CPP 4.9.9.2

22234

Output on MS Visual C++ 2008 Express Edition
version 9.0.30720.1 sp1

54352

--------------

Which one is wrong and why....?
If both are true than why  it happens..?

Regards,
Asad Abbas,
Pakistan.

[Non-text portions of this message have been removed]


________________________________
"DISCLAIMER: This message is proprietary to Aricent and is intended solely for 
the use of the individual to whom it is addressed. It may contain privileged or 
confidential information and should not be circulated or used for any purpose 
other than for what it is intended. If you have received this message in error, 
please notify the originator immediately. If you are not the intended 
recipient, you are notified that you are strictly prohibited from using, 
copying, altering, or disclosing the contents of this message. Aricent accepts 
no responsibility for loss or damage arising from the use of the information 
transmitted by this email including damage from virus."


[Non-text portions of this message have been removed]

Reply via email to