Length of array in function argument

前端 未结 8 1911
终归单人心
终归单人心 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条回答
  •  后悔当初
    2020-11-21 23:29

    int arsize(int st1[]) {
        int i = 0;
        for (i; !(st1[i] & (1 << 30)); i++);
        return i;
    }
    

    This works for me :)

提交回复
热议问题