Click here to Skip to main content
16,005,389 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: ++i and i++ Pin
vikas amin27-Dec-05 19:18
vikas amin27-Dec-05 19:18 
GeneralRe: ++i and i++ Pin
Nishad S27-Dec-05 20:10
Nishad S27-Dec-05 20:10 
GeneralRe: ++i and i++ Pin
segment_fault3-Jan-06 17:54
segment_fault3-Jan-06 17:54 
GeneralRe: ++i and i++ Pin
Nishad S27-Dec-05 20:11
Nishad S27-Dec-05 20:11 
AnswerRe: ++i and i++ Pin
Prakash Nadar27-Dec-05 21:42
Prakash Nadar27-Dec-05 21:42 
GeneralRe: ++i and i++ Pin
Nishad S27-Dec-05 21:52
Nishad S27-Dec-05 21:52 
GeneralRe: ++i and i++ Pin
vikas amin27-Dec-05 22:01
vikas amin27-Dec-05 22:01 
AnswerRe: ++i and i++ Pin
vikas amin28-Dec-05 0:29
vikas amin28-Dec-05 0:29 
Now i foudnd something that can prove
++i is better then i++.

this is in the case ur passing a argument
to a function in my case the fun name is
add. So ++i i better as it donot create any
temp variable to store . As the value is
need to be incremented first . But in the
late case the value have to be incremented
afterwards so a temp variable is needed..

Assmebly code to prove my words



U r wrong the case is vice versa
Tough to Belive

Assembly code to prove my observations

<br />
507:  Add(++i);<br />
004010CE   mov         eax,dword ptr [ebp-4]<br />
004010D1   add         eax,1<br />
004010D4   mov         dword ptr [ebp-4],eax<br />
004010D7   mov         ecx,dword ptr [ebp-4]<br />
004010DA   push        ecx<br />
004010DB   call        @ILT+15(Add) (00401014)<br />
004010E0   add         esp,4<br />
508:  Add(i+1);<br />
004010E3   mov         edx,dword ptr [ebp-4]<br />
004010E6   add         edx,1<br />
004010E9   push        edx<br />
004010EA   call        @ILT+15(Add) (00401014)<br />
004010EF   add         esp,4<br />





506:  Add(1+i);<br />
004010CE   mov         eax,dword ptr [ebp-4]<br />
004010D1   add         eax,1<br />
004010D4   push        eax<br />
004010D5   call        @ILT+15(Add) (00401014)<br />
004010DA   add         esp,4<br />
507:  Add(i++);<br />
004010DD   mov         ecx,dword ptr [ebp-4]<br />
004010E0   mov         dword ptr [ebp-5Ch],ecx<br />
004010E3   mov         edx,dword ptr [ebp-5Ch]<br />
004010E6   push        edx<br />
004010E7   mov         eax,dword ptr [ebp-4]<br />
004010EA   add         eax,1<br />
004010ED   mov         dword ptr [ebp-4],eax<br />
004010F0   call        @ILT+15(Add) (00401014)<br />
004010F5   add         esp,4




I dont know but how i+1 is more effecient to
pass then i++ or ++i





Vikas Amin
Embin Technology
Bombay
vikas.amin@embin.com
QuestionModelless dialog box Pin
pooja_12327-Dec-05 17:36
pooja_12327-Dec-05 17:36 
AnswerRe: Modelless dialog box Pin
Owner drawn27-Dec-05 17:41
Owner drawn27-Dec-05 17:41 
AnswerRe: Modelless dialog box Pin
Prakash Nadar27-Dec-05 21:56
Prakash Nadar27-Dec-05 21:56 
QuestionHow can I know if there is a Floppy disk in the Floppy drive? Pin
Owner drawn27-Dec-05 17:24
Owner drawn27-Dec-05 17:24 
AnswerRe: How can I know if there is a Floppy disk in the Floppy drive? Pin
Abhi Lahare27-Dec-05 19:12
Abhi Lahare27-Dec-05 19:12 
GeneralRe: How can I know if there is a Floppy disk in the Floppy drive? Pin
Owner drawn27-Dec-05 19:20
Owner drawn27-Dec-05 19:20 
GeneralRe: How can I know if there is a Floppy disk in the Floppy drive? Pin
Owner drawn27-Dec-05 19:57
Owner drawn27-Dec-05 19:57 
AnswerRe: How can I know if there is a Floppy disk in the Floppy drive? Pin
Blake Miller3-Jan-06 5:16
Blake Miller3-Jan-06 5:16 
Question__try/__except vs try/catch Pin
Chintoo72327-Dec-05 17:07
Chintoo72327-Dec-05 17:07 
AnswerRe: __try/__except vs try/catch Pin
S. Senthil Kumar27-Dec-05 18:51
S. Senthil Kumar27-Dec-05 18:51 
AnswerRe: __try/__except vs try/catch Pin
vikas amin27-Dec-05 19:00
vikas amin27-Dec-05 19:00 
Questionindexed palette in opengl Pin
P1P3R27-Dec-05 11:00
P1P3R27-Dec-05 11:00 
QuestionVisual Studio Bug ???? Pin
Shay Harel27-Dec-05 10:41
Shay Harel27-Dec-05 10:41 
AnswerRe: Visual Studio Bug ???? Pin
Dr Dan27-Dec-05 11:13
Dr Dan27-Dec-05 11:13 
GeneralRe: Visual Studio Bug ???? Pin
Shay Harel28-Dec-05 4:38
Shay Harel28-Dec-05 4:38 
AnswerRe: Visual Studio Bug ???? Pin
Gary R. Wheeler28-Dec-05 7:02
Gary R. Wheeler28-Dec-05 7:02 
GeneralRe: Visual Studio Bug ???? Pin
Shay Harel28-Dec-05 7:05
Shay Harel28-Dec-05 7:05 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.