0

Hello, day's greet!! I was trying to pass a 3D array. But the following code generate error. Please tell me where am I wrong and why.
Thanks a lot !!!!

#include<stdio.h>
void print_all(int [][][],int,int,int);

int main()
{       int degree=3, row=2, col=3;
        int arr[3][2][3] = {
                                {1,2,3,
                                 4,5,6
                                },
                                {7,8,9,
                                 10,11,12
                                },
                                {13,14,15,
                                 16,17,18
                                }
                           };
        print_all(arr[][2][3],degree,row,col);
return 0;
}


void print_all(int arr[][2][3],int degree,int row,int col)
{  int i,j,k;
        for(i=0;i<degree;i++)
        {       for(j=0;j<row;j++)
                {       for(k=0;k<col;k++)
                        {       printf("%d, ",arr[i][j][k]);
                        }
                        printf("\n");
                }
        printf("\n\n");
        }
}
2
Contributors
2
Replies
11
Views
2 Years
Discussion Span
Last Post by ram619
0

void print_all(int [][][],int,int,int);

All but the first dimension requires a size.

print_all(arr[][2][3],degree,row,col);

No indexing is required here, just use arr as the argument.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.