I am a totally beginner in programming and I have a question in the following code it's about creating a dynamic multidimensional array I don't understand the reason of p what's the function of it here
#include <iostream>
using namespace std;
void print2DArr(int** arp,int *ss,int nrows)
{
for(int i=0;i<nrows;i++){
for(int j=0;j<ss[i];j++){
cout << arp[i][j] <<" ";
}
cout << endl;
}
}
void main()
{
int count;
cout << "How many arrays you have?\n";
cin >> count;
int **arrs = new int*[count];
int *sizes = new int[count];
//int *arrs[3];//static array of pointers
for(int i=0;i<count;i++)
{
int size;
cout << "Enter size of array " << (i+1) << endl;
cin >> size;
sizes[i]=size;
int *p = new int[size];
arrs[i] = p;
//arrs[i] = new int[size];
cout << "Enter " << size << " values\n";
for(int j=0;j<size;j++)
//cin >> p[j];
cin >> arrs[i][j];
}
print2DArr(arrs,sizes,count);
//delete (dynamic de-allocation)
for(int i=0;i<count;i++)
delete[] arrs[i];
delete[] arrs;
}
std::vector<>would be a logical choice for implementing this with modern C++.