How to pass a 2D array by pointer in C?

char ** doesn’t represent a 2D array – it would be an array of pointers to pointers. You need to change the definition of printarray if you want to pass it a 2D array:

void printarray( char (*array)[50], int SIZE )

or equivalently:

void printarray( char array[][50], int SIZE )

Leave a Comment