How to pass a string array to a function?
That depends on what you mean by "string array", because it turns out that there are, sort of, two completely different types of "string" in C. Formally, a string is an array of characters. But since arrays almost always decay into pointers when you use them, it is extremely common to think about char * — that is, pointer-to-char — as also being a "string type" in C.
char array_slave_1[128][128];
This is an array of arrays of char. So it is usefully an array of strings, using the array definition of "string". It does have the limitation that none of the strings it contains can ever be longer than 127 characters.
int array_length(char *a[]) { ...
This function accepts an array of pointers to char. So it is also usefully an array of strings, using the pointer definition of "string". It is further apparent that you are trying to use an array of pointers here given that you are looking for a NULL pointer to mark the end of the array.
But! In this case, the two different types of "array of string" are not compatible! An array of arrays is completely different from an array of pointers. There are no automatic conversions that will let you start with one, and treat it as if it was the other.
(This is by contrast to the situation with simple, single strings, since the array-decay-to-pointer rule always lets you treat an array-string as if it were a pointer-string.)
Your best bet is probably to change
char array_slave_1[128][128];
to
char *array_slave_1[128];
Now you have an array of 128 pointer-strings. This will be compatible with your array_length function, and it will remove the limitation on the lengths of the individual strings in the array. On the other hand, you will need to change any code you have for initializing and manipulating the string in array_slave_1: Some of that code may still be fine, but anything that involves something like strcpy(array_slave_1[i], ...) will have to change. Depending on your needs, you may also need to call malloc to allocate space for each element in the array to point to.
char array_slave_1[128][128];and notchar * array_slave_1[128];for string array?array_lengthfor thearray_slave_1you have shown.array_slave_1is an array of arrays, which means eacharray_slave_1[i]is an array. Since eacharray_slave_1[i]is an array, whenever it is used an expression other than as the operand ofsizeofor the operand of unary&, it will be converted to the address of its first element. That will never be a null pointer. Your loop will eventually overrun the length of the array, and then the behavior is not defined by the C standard. You need to explain the problem further and in more detail.