N
newtothis
I have been reading various texts in C/ C++ and Java. The for lops all
run along the lines of :
int i ;
for(i = 0 ; i < 4 ; i++)
{
.....
}
I understand the difference between ++i and i++, but I can not see why
i++ is used in these loops when, as I understand it, the steping
expression would be more alined to i = i + 1 in this type of case. The
logic of i++ is not the same. The final result might but the evaluation
process is not.
Ok I realise at the end of the loop the value of i is the same which
ever method you use. But that does not explaine why the preference.
Also from what I can see at the assembly code level
int i ;
for(i = 0 ; i < 4 ; ++i)
{
.....
}
and
int i ;
for(i = 0 ; i < 4 ; i++)
{
.....
}
are exactly the same.
Could some please explain the need to use i++ over ++i.
run along the lines of :
int i ;
for(i = 0 ; i < 4 ; i++)
{
.....
}
I understand the difference between ++i and i++, but I can not see why
i++ is used in these loops when, as I understand it, the steping
expression would be more alined to i = i + 1 in this type of case. The
logic of i++ is not the same. The final result might but the evaluation
process is not.
Ok I realise at the end of the loop the value of i is the same which
ever method you use. But that does not explaine why the preference.
Also from what I can see at the assembly code level
int i ;
for(i = 0 ; i < 4 ; ++i)
{
.....
}
and
int i ;
for(i = 0 ; i < 4 ; i++)
{
.....
}
are exactly the same.
Could some please explain the need to use i++ over ++i.