I've typically shied away from unnecessary C++ features but as time marches on I can't avoid confronting my gremlins. Most recent of all is operator new[]
and the potential for memory problems.
char *playerNewNames = new char[numPlayers][50];
It's great to know we don't need so many pointer *
indirections and I'd feel confident in C iterating with malloc
but the above seems a step too far. My compiler didn't complain but I want to be sure I will be getting an array of size numPlayers
with each indexing a tranche of 50 characters. And how would I deallocate this?
I will try delete[][]
but even if that doesn't throw it isn't 100% obvious that it will clean up everything, without iteration on my part. Please can somebody explain. Thanks in advance.