help..dynamic multidimensional arrays

ava

Joined
Jul 9, 2009
Messages
1
Reaction score
0
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,066
Latest member
VytoKetoReviews

Latest Threads

Top