1

Possible Duplicates:
Passing multidimensional arrays as function arguments in C
Converting multidimensional arrays to pointers in c++

Hi,

I try to pass 2 dimension arrays to function in C, and the following code works

 void printArray(int a[][4], int size) {
        int i = 0;
        for (; i < size; ++i) {
            int j = 0;
            for (; j < size; ++j) {
                printf("%d,", a[i][j]);
            }
            printf("\n");
        }
    }

but if I replace "int a[][4]" to "int **a" it won't work, can anyone tell what's the difference ?

Thanks

Community
  • 1
  • 1
zjffdu
  • 25,496
  • 45
  • 109
  • 159

1 Answers1

9

Obligatory link: http://c-faq.com/aryptr/pass2dary.html. Everything you need to know should be in there; I won't bother writing it all out here...

Oliver Charlesworth
  • 267,707
  • 33
  • 569
  • 680