Fw: Re: thanks for the advice, and spaceship

Hiroko Terasawa Hiroko.Terasawa@stanford.edu
Tue, 13 May 2003 22:57:54 -0700


Hi Jeffyb and his funny companies, 

I tried a short script, and works ok. Both shows output of 01234. 
I was not sure if the preincrement might show output of 12345. 

When does for loop execute the i++ or ++i statement, before or after
execution of the {} contents? The reason why people appreciate i++
rather than ++i might be traditional? The old days when there were too
many confusing languages (like fortran), it might have been possible
that the following code come up with 12345. 

I have Karnighan book with bunch of i++, by the way. 


#include <iostream.h>
int main(){
  int i;
  cout << "preincrement" << endl;
  for(i=0; i<5 ; ++i){
    cout << i << endl;  }
  cout << "postincrement" << endl;
  for(i=0; i<5 ; i++){
    cout << i << endl;  }
  return 0;
}



-- 
Hiroko Shiraiwa-Terasawa <Hiroko.Terasawa@stanford.edu>