From the code you've shown, vector[i+1].c_str()
will read beyond the end of vector
for the last iteration of the loop.
Should you exit your loop one iteration sooner?
for(int i=0; i<vector.size()-1;i++)
If this doesn't help, can you post a fuller example that demonstrates the problem? It isn't currently possible to say whether e.g. vector2
has sufficient capacity or vector
's contents will always be convertible into suitable indexes.