Hello ladies and gents,
I'm trying to output a 2D array, but can't seem to find the solution, can anyone help me out here.
#include <stdafx.h>
#include <iostream>
using namespace std;
int main()
{
int **pp;
int i, j, n, ni;
cout<<"Geef het aantal regels als volgt: ";
cin>> n;
pp = new int *[n];
for (i = 0; i < n; i++)
{
cout<<"Geef ni, de lengte van de eerstvolgende regel: ";
cin>> ni;
pp[i] = new int[ni];
cout<<"Tik "<< ni <<" getallen in:\n";
for(j = 0; j < ni; j++)
{
cin>> pp[i][j];
}
}
for(i = 0; i < n; i++)
{
ni = sizeof ?????
for(j = 0; j < ni; j++)
cout<< pp[i][j] <<" ";
cout<<endl;
}
for(i = 0; i < n; i++)
delete[] pp[i];
delete[] pp;
cout<<"Press any key to quit!\n";cin.get();
return 0;
}
I know I have to use the size of each row of the array, but fail to see wich piece of code I have to use to write next to sizeof
for(i = 0; i < n; i++)
{
ni = sizeof ?????
for(j = 0; j < ni; j++)
cout<< pp[i][j] <<" ";
cout<<endl;
}
Any help would be greatly appreciated :)