如何通过2维数组在C中发挥作用? [英] How to pass 2 dimension arrays to function in C?

查看:160
本文介绍了如何通过2维数组在C中发挥作用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

可能显示的文件:结果
  <一href=\"http://stackoverflow.com/questions/4051/passing-multidimensional-arrays-as-function-arguments-in-c\">Passing多维数组在C 结果的函数参数
  <一href=\"http://stackoverflow.com/questions/1584100/converting-multidimensional-arrays-to-pointers-in-c\">Converting多维数组在C ++

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

我试图通过2维数组在C中发挥作用,
以下code ++工程

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

但如果我替换诠释一个[] [4]诠释**了
它不会工作,任何人都可以告诉有什么区别?

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

感谢

推荐答案

强制性链接:的http:// C-FAQ。 COM / aryptr / pass2dary.html 。你需要知道应该在那里的一切;我不会打扰在这里写了这一切......

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

这篇关于如何通过2维数组在C中发挥作用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆