I have a vector of char arrays declared as such:
I add stuff to it like this (alias is a const char* passed to the add function):
So being that I dynamically added it, i assume i would have to delete all of them on close, like such:
The 'delete [] aliasList' generates a huge error with a big fat X and a loud alert sound. It says:
"Damage: After normal block #228" etc.
Can anyone tell me why it doesn't like that line? I've also tried this:
It doesn't work either, although being each element in the vector is an array of chars, the first is the one I would think I should use.
If someone could either tell me why it doesnt like that code or if its even necessary to delete these elements, that be awesome. Thanks!
Code:
vector <char*> aliasList;
I add stuff to it like this (alias is a const char* passed to the add function):
Code:
aliasList.push_back(new char[strlen(alias)]);
strcpy(aliasList.back(), alias);
So being that I dynamically added it, i assume i would have to delete all of them on close, like such:
Code:
if (aliasList.size()){
for (int i = 0; i < aliasList.size(); i++){
delete [] aliasList[i];
}
aliasList.clear();
}
The 'delete [] aliasList' generates a huge error with a big fat X and a loud alert sound. It says:
"Damage: After normal block #228" etc.
Can anyone tell me why it doesn't like that line? I've also tried this:
Code:
delete aliasList[i]
It doesn't work either, although being each element in the vector is an array of chars, the first is the one I would think I should use.
If someone could either tell me why it doesnt like that code or if its even necessary to delete these elements, that be awesome. Thanks!