Skip to content

Instantly share code, notes, and snippets.

@gabrielbiga
Created June 11, 2014 18:07
Show Gist options
  • Save gabrielbiga/8f67b09432ff54aa44a6 to your computer and use it in GitHub Desktop.
Save gabrielbiga/8f67b09432ff54aa44a6 to your computer and use it in GitHub Desktop.
Passing a pointer of a 2D array to function
#include <stdio.h>
#define LIN 2
#define COL 2
void mostraMatriz(int (*matriz)[LIN][COL]) {
printf("%d\n", (*matriz)[0][1]); //retorna 2
}
int main() {
int matriz[LIN][COL] = {
{5, 2},
{1, 6}
};
mostraMatriz(&matriz);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment