Download MetaTrader 5

Need help to spot some slight error . - page 5

To add comments, please log in or register
whroeder1
15335
whroeder1  
juniorlcq: let's say OrdersTotal() == 3 , with the count down for loop for ( int x = ( OrdersTotal() - 1 ) ; x >= 0 ; x-- ) , x will save the 1st value as 2 , then it will continue the for loop from 2 onwards without going through OrdersTotal() again ??
Yes. It does that wither you used x-- or --x. For and while are interchangeable.
int x = OrdersTotal() - 1; // OT retrieved only once.
while(x >= 0){
  :
  --x;
}
The difference is x-- retrieves the original value 2 after making x=1 before throwing the value away. (The value isn't used, unlike arr[x--])
12345
To add comments, please log in or register