Length of array in function argument

前端 未结 8 1913
终归单人心
终归单人心 2020-11-21 23:05

This is well known code to compute array length in C:

sizeof(array)/sizeof(type)

But I can\'t seem to find out the length of the array pass

8条回答
  •  Happy的楠姐
    2020-11-21 23:46

    Best example is here

    thanks #define SIZE 10

    void size(int arr[SIZE])
    {
        printf("size of array is:%d\n",sizeof(arr));
    }
    
    int main()
    {
        int arr[SIZE];
        size(arr);
        return 0;
    }
    

提交回复
热议问题