Original Post
Using C with classes in VS 2003. I've made a little system where an array of pointers to chars (like: char *names[MAX_NAMES]) is used to allocate an unknown amount of names (less than MAX_NAMES) of unknown length. There are other pointers to pointers that share the same names from elsewhere in the program, so that it's easy to change a name and have the name "changed" anywhere it is used in the program. Like: char **ptp; //from somewhere else ptp = &names[ NameAskedFor ]; It all works well when running the application normally but when it's time to shut it down it crashes sometimes (and sometimes not) - but that's only when i've changed the names in the array of pointers during the run. When I change the names in the array, I delete the pointer to the name I want to change and assign it a new array of chars depending on the size of the new name in bytes and so forth - nothing strange really. Is there something I'm doing wrong when working this way? It crashes in the very end of the application. Also I'm using a singleton class that stores the array of pointers to chars and a dynamic amount of menus that uses these names through their own pointer to pointer. When the application is shuting down I call an uninitalize function for the singleton name-class (with no crashes there wether or not i've changed names during the run) and delete the menus as well without errors. The crash occurs at the very end of the application. Sorry for the long "question", but I just want to know if I should worry about the way I'm treating the pointers to the pointers/array of pointers or if I should aim to solve the problem elsewhere in the program? Is it screwing with the stack or something?