Suppose we have a double pointer char **t; Logically suggested that if char* t1=new char[2]; then char **t=new *char[2]; will work, but alas it turned out wrong. So after all, how to expand memory for it and can a double pointer contain an array of pointers?

    2 answers 2

    1. You can allocate memory in this way, about how beautiful it is, you can try to speculate, knowing in more detail your task.

      char **t = new char*[2];

    2. You can use a pointer to a pointer to organize an array of pointers, just remember that, in addition to allocating memory for an array of pointers, you will need to allocate memory and for each element of the array.

    • Thank you very much! All clear! - Djonny
    • one
      Not at all, but I advise you not to take answers too quickly. Let some points of view accumulate. First, the answer offered quickly may turn out to be incorrect, and second, several answers, complementing each other, may help to get a more complete picture of the methods of solving the problem. - northerner
    • Good! By the way, in a hurry I forgot to ask, and the release of memory for such an array is implemented by the operation delete [] t ;? - Djonny
    • Just do not forget before this, free the memory allocated for the elements. - northerner
    • well this is logical) - Djonny

    Would add:

    "Logically suggested ..." is not logical!

    For any type T, type T * means “pointer to object of type T”