Hello again,

my code runs each item of a map and I would like to stop before the last item is reached. I would be thrilled if anybody can explain...

Code:
typedef map<int, int>   M;
typedef M::iterator     It;

M m;

m[1] = 1;
m[2] = 2;
m[3] = 3;


for (It it=m.begin(); it != m.end(); ++it) {
  
  if (it == m.end() -1)   // ?
    cout << "pre-last item found: " << it->second;   // result 2
}




sincerly,
Necip


a bit more about me on processing8.wordpress.com