Do you mean the number of rows in the array?
If the array was allocated on the stack in the same block, you can use the trick sizeof(foo)/sizeof(foo[0]).
const char *foo[] = { "abc", "def" };
const size_t length = sizeof(foo)/sizeof(foo[0]);
If you are talking about argvtransferred to the main, you can look at the parameter argc.
If the array was allocated on the heap or passed to the function (where it will decay to a pointer), you are out of luck, unless someone passed the size to you.
source
share