I need help for calculate the number of element of the array of pointer inside a function.
This is not possible. When you pass an array to a function it decays to a pointer and you loose all size information. You need to either keep track of the array size, or compute the size in the function where the array is declared. You should always pass the size of the array into the function as another parameter.
Code:
unsigned int read_file(char*my_filename[], size_t array_size);
int main(int argc, char* argv[])
{
unsigned int num_file=0;
char * my_filename[]={"a","b","c"};
size_t array_size = sizeof(my_filename)/sizeof(my_filename[0]);
num_file=read_file(my_filename, array_size);
printf("%d\n",num_file);
return 0;
}
Jim