Skip to content

Instantly share code, notes, and snippets.

@surinoel
Last active July 16, 2019 10:04
Show Gist options
  • Save surinoel/77b3e5e235f8917c5fd3c4ac059b152b to your computer and use it in GitHub Desktop.
Save surinoel/77b3e5e235f8917c5fd3c4ac059b152b to your computer and use it in GitHub Desktop.
#if 0
반환값자료형 함수이름(자료형 매개변수[][가로크기])
{
}
반환값자료형 함수이름(자료형(*매개변수)[가로크기])
{
}
#endif
#include <stdio.h>
// 혹은 void pointerArray(int (*arr)[5], int col, int row)
void pointerArray(int arr[][5], int col, int row) {
for (int i = 0; i < row; i++) {
for (int j = 0; j < col; j++) {
printf("%d ", arr[i][j]);
}
printf("\n");
}
}
int main(void) {
int numArr[2][5] = {
{ 1, 2, 3, 4, 5 },
{ 6, 7, 8, 9, 10 }
};
int col = sizeof(numArr[0]) / sizeof(int);
int row = sizeof(numArr) / sizeof(numArr[0]);
pointerArray(numArr, col, row);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment