Welcome to AndreiL.
Enjoy your time.
Please log in.

N dimension array - C

Go down

N dimension array - C Empty N dimension array - C

Post by Lucaci Andrei on Thu Mar 22, 2012 10:09 pm


int main(){
int **** a;
int m, n, p, q, sum=0, i, j, k, l;
printf ("Dimensions (4 numbers separated by space): \n");
scanf ("%d %d %d %d",&m, &n, &p, &q);
printf ("\n");
a=(int****) malloc(m*sizeof(int***));
for (i=0; i<m; i++){
for (j=0; j<n; j++){
for (k=0; k<p; k++){
a[i][j][k]=(int*)malloc(q*sizeof (int));
for (l=0;l<q;l++){
for (i=0; i<m; i++){
for (j=0; j<n; j++){
for (k=0; k<p; k++){
free (a[i][j][k]);
free (a[i][j]);
free (a[i]);
free (a);
printf ("Sum is %d", sum);
printf ("\n\n");
return 0;

Lucaci Andrei
Lucaci Andrei
"Tata Lor"
N dimension array - C 138

Number of messages : 222
Points : 2266743
Reputation : 1007
Registration date : 2008-08-15
Age : 26
Location : Cluj-Napoca

View user profile

Back to top Go down

Back to top

Permissions in this forum:
You cannot reply to topics in this forum