C Program: newbie trying to pass 2D string array into a function
c
Solution
A two-dimensional array of characters is still a character array and would have a prototype of `char *my_array`. So just change your function definition to this:
void my_function(char *my_array)
Note that this will flatten the array. There are different techniques to keep the two-dimensional-ness of the array, an easy way is to use this alternative prototype:
void my_function(char my_array[][COLS])
Which will preserve your array's dimensions when passed.
`char **my_array` means something completely different (pointer to an array, for example).
Problem
Programming in C ( with -std=C89), and running into errors trying to pass a character string array into a function. In `main()`, I've declared the array as follows: ``` #define ROWS 501 #define COLS 101 void my_function( char **); ... char my_array[ROWS][COLS]; ... my_function(my_array); ``` In `my_function`, I've declared the array as: ``` void my_function( char **my_array ) { ... } ``` I'm getting this error: `warning: passing argument 1 of 'my_function' from incompatible pointer type, note: expected 'char **' but argument is of type 'char (*)[101]`