different answer for same code in linux ,Eclipse IDE

K

khadar

Hello

I am executing the following code in both Linux,turbo C and Eclipse
IDE(in windows) 3.2 ,CDT 3.0.

code :

# include <stdio.h>

main()
{
int a=1;
a=a++ * ++a;
printf("a=%d\n",a);
}

In both Linux and turbo C ,the result is 5 but in Eclipse IDE result
is 4 , Why this happend .
Please proper clarification.

Thank you.
 
M

manoj1978

khadar said:
Hello

I am executing the following code in both Linux,turbo C and Eclipse
IDE(in windows) 3.2 ,CDT 3.0.

code :

# include <stdio.h>

main()
{
int a=1;
a=a++ * ++a;
printf("a=%d\n",a);
}

In both Linux and turbo C ,the result is 5 but in Eclipse IDE result
is 4 , Why this happend .
Please proper clarification.

Thank you.
Read comp.lang.c FAQ list · Question 3.2
 
C

Chris Dollin

khadar said:
Hello

I am executing the following code in both Linux,turbo C and Eclipse
IDE(in windows) 3.2 ,CDT 3.0.

code :

# include <stdio.h>

main()
{
int a=1;
a=a++ * ++a;

Undefined behaviour; see the FAQ. (You write to the same location,
`a`, /three/ times in a single complete expression; that's
explicitly undefined behaviour. Even if it were not, what makes
you think that your idea of order-of-execution and the compiler's
have to be the same?)
 
K

Keith Thompson

Spiros Bousbouras said:
(e-mail address removed) wrote: [...]
Read comp.lang.c FAQ list · Question 3.2

Which can be found at
http://c-faq.com/expr/evalorder2.html

Yes, but the front page, <http://www.c-faq.com/>, says:

[Note to web authors, catalogers, and bookmarkers: the URL
<http://www.c-faq.com/> is the right way to link to these
pages. All other URL's implementing this collection are subject to
change.]

When I cite the FAQ, I always provide the URL for the front page and
the question number rather than the URL of the specific question, both
for the reasons stated above and because it encourages readers to
browse the rest of the FAQ.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,430
Messages
2,571,676
Members
48,796
Latest member
Greg L.

Latest Threads

Top