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");
        }
}

Recommended Answers

All 2 Replies

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.

Thanks a lot !

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.