Created
June 11, 2014 18:07
-
-
Save gabrielbiga/8f67b09432ff54aa44a6 to your computer and use it in GitHub Desktop.
Passing a pointer of a 2D array to function
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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