Programming Tips - How do I convert an integer index into a STL vector into

Date: 2003Aug12 Language: C++ Q. How do I convert an integer index into a STL vector into and iterator? I need an iterator for insert(). A. Do this:
#include <vector> typedef std::vector<char *> MYARRAY; void insert_with_index(MYARRAY &a, const int index, char *s) { MYARRAY::iterator it; it = &a[index]; // Convert the index to an iterator it = a.begin() + index; // Another way a.insert(it, s); }