Q:

dynamically allocating atwo dimensional array where each row contains variable number of elements & freeing it in c++

How can I dynamically allocate a two dimensional array where each row contains variable element? How can I free this memory?

A:

Actually you probably want a vector of vectors, something like this:
std::vector<std::vector<int> > vector_2d;

This way you'll benefit from the automatic memory management of the vector rather than having to manually manage the memory of an array of pointers to arrays of data.

