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

前端 未结 11 1826
陌清茗
陌清茗 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:19

    you have to end the array with a special value and in called function you have to count up to that value that is how strlen() works it counts up to NULL '\0' value.

提交回复
热议问题