开发者

How to pass 2 dimension arrays to function in C? [duplicate]

开发者 https://www.devze.com 2023-02-06 07:10 出处:网络
This question already has answers here: Closed 12 years ago. Possible Duplicates: Passing multidimensional arrays as function arguments in C
This question already has answers here: Closed 12 years ago.

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 co开发者_开发知识库de 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


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...

0

精彩评论

暂无评论...
验证码 换一张
取 消