I m beginner in c++. I m trying to shuffle the string to different positions in the vector array. I have written the code. Its giving the runtime error. Please help me out.
I m passing "hello", "mellow","jello","yello" if I do the "push_back" it automatically stores in the vector array positions at 0 1 2 3 respectively. But I want to store at 3 1 2 0 positions. Thanks in advance..
This is not a vector. It's a pointer. It doesn't actually point to anything.
Later, when you call insert (and begin), you are dereferencing a bad pointer and trying to insert elements to a non-existent vector. Hence the runtime error.
Furthermore, push_back would be much simpler than insert... since you're always adding to the end of the array... but that's a side issue.
For your main problem, use an actual vector object instead of a pointer:
1 2 3 4 5 6 7 8 9 10
vector<constchar *> option; // <- no *, so it's an object
// now that you have an actual object, you can do this:
it = option.begin();
// or, more simply, this:
option.push_back( options[i] );