思考一段关于多维数组的程序

603阅读 0评论2006-12-11 jeffshia
分类:C/C++

/*

 * Test this code and think why it acts as that?

 */

 

#include<stdio.h>

void foo(int b[][3]);

int main(void)
{
    int a[3][3]=
    {
        {1,2,3},
        {4,5,6},
        {7,8,9}
    };
   
    printf("a[2][1] before foo is:%d\n", a[2][1]);
    foo(a);
    printf("a[2][1] after foo is:%d\n", a[2][1]);

    return 0;
}

void foo( int b[][3])
{
    ++b;
    b[1][1]=9;    
}

上一篇:code helping you to understand function stack
下一篇:听一首伤感的情歌