C: finding the number of elements in an array[]

前端 未结 11 1799
陌清茗
陌清茗 2020-12-16 14:31

In C: How do you find the number of elements in an array of structs, after sending it to a function?

int main(void) {
  myStruct array[] = { struct1, struct2         


        
11条回答
  •  隐瞒了意图╮
    2020-12-16 15:02

    As the C reference says, you cannot do this unless either the last element is unique or you pass a count of array elements to the function.

提交回复
热议问题