DIGIT-ARC read-only archive · snapshot: July 23, 2026

Microsoft Visual C++ or TC++ or what

5 posts · originally from https://geek.digit.in/community/threads/microsoft-visual-c-or-tc-or-what.47284/

S
sharptooth Original post #1
Jan 23, 2007 at 11:40 PM
Well if this not a bug than i dont understand wat it is?

i today found that "Microsoft Visual C++" v6.0 on which i performed most of my c and c++ projects, has a bug. i cud not believe it, it was a total annoy for me.

run this problem on MSVisualC++:

Code:
int x=5,y; 
y=++x + ++x; 
cout<<y;

the output is 14 in MSVisualC++, strange, it shud be 13.

in tc++ however it gives the correct output as 13, also 13 on C# compiler.

Now can anyone here try to clarify why MSVisualC++ gave wrong output? ?
Manshahia
Jan 26, 2007 at 6:29 PM
Wat is the Difference btw Visual C++ & TC?
morpheusv6
Jan 28, 2007 at 2:05 AM
My TC++ 3.0 shows 14.
mediator
Jan 28, 2007 at 4:21 AM
No, the output shud be 14.

I have lost touch in C++, but AFAIK for "++x" , the increment is done before the execution of the whole line. Likewise for "x++", the increment is done after the execution of the whole line.

Try this out n observe!
#include<iostream.h>
int main()
{
int x=5,y;
cout<<"\nFor x++"<<endl;
y=x++ + x++;
cout<<"x = "<<x<<endl;
cout<<"y = "<<y<<endl;

x=5,y;
cout<<"\nFor ++x"<<endl;
y=++x + ++x;
cout<<"x = "<<x<<endl;
cout<<"y = "<<y<<endl<<endl;
return 0;
}
Pathik
Pathik #5
Jan 28, 2007 at 5:02 AM
no way man the o/p shd b 13 only