Passing an int array of variable length as a function parameter in Objective C

前端 未结 5 1637
佛祖请我去吃肉
佛祖请我去吃肉 2021-01-12 13:04

I have the following code which works fine...

int testarr[3][3] = {
  {1,1,1},
  {1,0,1},
  {1,1,1}
};   
[self testCall: testarr];

Which c

5条回答
  •  伪装坚强ぢ
    2021-01-12 13:58

    call

    int testarr[3][3] = {
      {1,1,1},
      {1,0,1},
      {1,1,1}
    };   
    [self testCall: (int *)testarr];
    

    function

    - (void)testCall: (int *) arr 
    {
        int (*V_arr)[3] = (int(*)[3])arr;
        NSLog(@"cell value is %u",V_arr[1][1]);
    }
    

提交回复
热议问题