hello
i was trying a simple code..of creating multidimensional array using pointer..it compiled but gave segmentation fault on execution
the code is
#include<iostream>
using namespace std;
int main()
{
int i,j,k,i1,j1,k1;
int ***a=NULL;
int ***b=NULL;
cin>>i;
cin>>j;
cin>>k;
b=new int**;
a=new int**;
for(i1=0;i1<i;i1++)
{b=new int*[j];
a=new int*[j];
for(j1=0;j1<j;j1++)
{b[j]=new int[k];
a[j]=new int[k];
for(k1=0;k1<k;k1++)
cin>>b[i1][j1][k1];
}}
for(i1=0;i1<i;i1++)
for(j1=0;j1<j;j1++)
{cout<<"\n";
for(k1=0;k1<k;k1++)
cout<<" "<<b[i1][j1][k1];
}
}
PLZ HELP
i was trying a simple code..of creating multidimensional array using pointer..it compiled but gave segmentation fault on execution
the code is
#include<iostream>
using namespace std;
int main()
{
int i,j,k,i1,j1,k1;
int ***a=NULL;
int ***b=NULL;
cin>>i;
cin>>j;
cin>>k;
b=new int**;
a=new int**;
for(i1=0;i1<i;i1++)
{b=new int*[j];
a=new int*[j];
for(j1=0;j1<j;j1++)
{b[j]=new int[k];
a[j]=new int[k];
for(k1=0;k1<k;k1++)
cin>>b[i1][j1][k1];
}}
for(i1=0;i1<i;i1++)
for(j1=0;j1<j;j1++)
{cout<<"\n";
for(k1=0;k1<k;k1++)
cout<<" "<<b[i1][j1][k1];
}
}
PLZ HELP