vector<int>::iterator iter1 = ivec.begin(); int i = 1; for(vector<int>::iterator iter = ivec.begin(); iter != ivec.end(); iter++) { *iter = i++; }