An alternative to using new and delete is to use the STL (standard template library) vector class - then you don't need to worry about deallocating since the vector class handles it.
E.g.
#include <vector>
void foo()
{
std::cin >> len;
std::vector<int> a(len);
}
Regards,
Ian.