dynamic memory in C uses malloc(), or a similar function, to allocate dynamic memory and free() to delete dynamic memory. In C++ it's new() and delete. In either case, if you want memory for an array of items then you add the [] operator, as appropriate.

Neither C nor C++ have built in array size detection. The C++ STL class do include that "technology", and for that reason alone, it may be worth your while to consider dumping arrays/C style strings and learn about the STL vector and string classes. Having said that, there isn't anything wrong with learning how to adjust your arrays so they fit "just right". Most people find it boring to do this all the time, and it's not worthwhile from a memory standpoint or a speed standpoint on most computers, but it is a reasonable learning project.

To get array sizes just right you need to somehow keep track of the current size of the array and the capacity of the array. If the size of the array equals the capacity of the array and you want to add to the array, then you need to expand the array, and if the size is less than the capacity, then you need to decrease the size of the array. You start by declaring a temporary array of the size of the current array and copy the data from the current array into the temporary array. You then delete the memory from the current array and redeclare with just the right amount of memory you want/need. Then you copy the information in the temporary array back into the original array and delete the temporary array. Here's an example using char arrays and C++. It's a bit different using other types of arrays, but the basic theory is the same.