I'm having a problem processing a multidimensional array. I'm trying to get "123" "456" "x123" and "x456" to appear on screen inside a function using pointers:
void f(char ***array){
while (**array != '\0'){
while (*array != '\0'){
printf("%s\n",*array);array++;
}
}
}
int main(){
char* arr[50][50]={{"123","456"},{"X123","X456"}};
f(arr);
return 0;
}
When compiling, I receive the warning passing argument 1 of 'f' from incompatible pointer type
at the line f(arr);
. and when running the code, I see:
123
456
Segmentation fault
and the program exits.
When I change my code to this:
void f(char **array){
while (*array != '\0'){
printf("%s\n",*array);array++;
}
}
int main(){
char* arr[50]={"123","456"};
f(arr);
return 0;
}
The numbers iterate fine, but I'd rather group my data into sets at some point for better organization. Why does the first set of code with multidimensional array not execute properly?