merman said:
Hi,
how can I get the length of an array:
char *test[] = {"a", "b", "c", NULL};
/* This is a FAQ. Check the FAQs _before_ posting */
#include <stdio.h>
int main(void)
{
char *test[] = { "a", "b", "c", NULL };
printf("WARNING: The numbers produced by this program\n"
"are implementation-dependent.\n"
"The test array has a total size of %lu,\n"
" is composed of elements of size %lu.\n"
"So there are %lu elements.\n",
(unsigned long) sizeof test,
(unsigned long) sizeof *test,
(unsigned long) (sizeof test / sizeof *test));
return 0;
}
WARNING: The numbers produced by this program
are implementation-dependent.
The test array has a total size of 16,
is composed of elements of size 4.
So there are 4 elements.