find the number of strings in an array of strings in C

前端 未结 9 1378
长发绾君心
长发绾君心 2020-12-13 18:00
char* names[]={\"A\", \"B\", \"C\"};

Is there a way to find the number of strings in the array. Like, for example in this case, it has to be 3. Ple

9条回答
  •  时光说笑
    2020-12-13 18:25

    int count = sizeof(names)/sizeof(*names);
    

    This takes the total size of names and divides it by the size of one element in names, resulting in 3.

提交回复
热议问题