If you want to pass variable length arrays, then either you need to pass the length, or the array needs a terminator. For arrays of pointers to char (which is what an array of C strings is), a good choice is to use NULL as a terminator rather than using a zero-length string. In conditional expressions, a NULL is treated as a logical false, and this creates compact code that other C programmer can understand.
The type of these paramters is [nobbc]char **x[/nobbc], or equivalently [nobbc]char *x[][/nobbc]
char *array1[] = {"one","two","three",NULL};
char *array2[] = {"alpha","Baker","charlie","delta",NULL};
void foo(char **s) {
while(*s) {
Serial.print(*s);
s++;
}
}
void bar() {
foo(array1);
foo(array2);
}
Although the name 'array1' is a constant, the name 's' in the function 'foo' is not.
To do the equivalent the way you are doing it - using a pointer to an empty string as the terminator, you would:
char *array1[] = {"one","two","three",""};
char *array2[] = {"alpha","Baker","charlie","delta",""};
void foo(char **s) {
while(**s) { // DETECT IF THE INDEXED STRING IS OF ZERO LENGTH
Serial.print(*s);
s++;
}
}
void bar() {
foo(array1);
foo(array2);
}
Using "\0" is unnecessary - the double quotes already get a nul-terminated string. Using "\0" crates an array of char of length 2.