If I want to dynamically create an int array in C++ and then delete it later, do I need to null terminate the int array? If so, how do I do it? If not, how does the computer know how much memory to free?
int *array = new int[x];
..do some stuff..
delete array;
I know for a char array it deletes up to a null character ('\0') and if you don't have a terminating null character in your string you'll probably get memory violation errors but how does this apply to arrays of ints (and other arrays, like arrays of structs)?
std::vector<int>, which manages the memory for you, or use astd::unique_ptr<int[]>/std::shared_ptr<int[]>/boost::shared_array<int>/boost::scoped_array<int>, which will destroy the array at the correct time.&v[0], you can have direct access to the array contained within for functions that accept pointers.