I am having a problem with freeing array of strings. I have a program but I made this simple code to see the error:
char *cardsName[2];
cardsName[0] = new char[3];
cardsName[0] = "a";
cardsName[1] = new char[3];
cardsName[1] = "c";
for(int i=0;i<2;i++)
delete(cardsName[i]);
This giving me error munmap_chunk(): invalid pointer: 0x080489b8 ***
and this also giving me error:
char *cardsName[2];
cardsName[0] = new char[3];
cardsName[0] = "a";
cardsName[1] = new char[3];
cardsName[1] = "c";
delete []cardsName;
free(): invalid pointer: 0xbfc38dd8 ***
Then how I do free for array of pointers to char,... I really need it for my program and I really searched a lot and I can't find solution for this simple problem.
std::arrayandstd::string?