Forum     

Go Back   Digit Technology Discussion Forum > Software > Software Q&A
Register FAQ Calendar Mark Forums Read

Software Q&A Having trouble with software? Find solutions here

Closed Thread
 
LinkBack Thread Tools Display Modes
Old 23-01-2007, 11:40 PM   #1 (permalink)
Right Off the Assembly Line
 
Join Date: Jan 2007
Location: edge of hell.
Posts: 12
Question Microsoft Visual C++ or TC++ or what

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? ?
sharptooth is offline  
Advertisements. Register and be a member of the community to get rid of them.
Advertisement

Old 26-01-2007, 06:29 PM   #2 (permalink)
Resident Fanatic
 
Manshahia's Avatar
 
Join Date: Jul 2006
Location: /Milky way/earth/india/
Posts: 910
Default Re: Microsoft Visual C++ or TC++ or what

Wat is the Difference btw Visual C++ & TC?
__________________
----------
Manshahia is offline  
Old 28-01-2007, 02:05 AM   #3 (permalink)
In The Zone
 
morpheusv6's Avatar
 
Join Date: Dec 2006
Location: Bangalore
Posts: 215
Default Re: Microsoft Visual C++ or TC++ or what

My TC++ 3.0 shows 14.
__________________
Deven
morpheusv6 is offline  
Old 28-01-2007, 04:21 AM   #4 (permalink)
String Phreak
 
mediator's Avatar
 
Join Date: Mar 2005
Location: In ur Evil Mind!
Posts: 2,453
Default Re: Microsoft Visual C++ or TC++ or what

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!
Quote:
#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;
}
__________________
Bad Bad server.....No candy for u!
mediator is offline  
Old 28-01-2007, 05:02 AM   #5 (permalink)
Google Bot
 
Pathik's Avatar
 
Join Date: Aug 2005
Posts: 9,751
Default Re: Microsoft Visual C++ or TC++ or what

no way man the o/p shd b 13 only
Pathik is offline  
Closed Thread

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +5.5. The time now is 09:38 PM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2012, vBulletin Solutions, Inc.

Search Engine Optimization by vBSEO 3.3.2