I have a vector of wchar_t* like this:
std::vector<wchar_t*> myvector;
and a function that take a string and insert it into the vector
void myfunction(wchar_t* mystring)
{
myvector.push_back(mystring);
}
myfunction(L"this is my string");
when I close the program I need to delete the allocated memory of the vector so that I don't have a memory leak, to do this I'm trying to do this:
for (std::vector<wchar_t*>::iterator it = myvector.begin(); it != myvector.end(); ++it)
{
delete [] *it;
}
it compiles, all works fine but when it's time to deallocated the memory I have a rountime error:
error http://k.min.us/iklWGE.png
why? how can I fix this?