Created
June 5, 2014 07:17
-
-
Save K-atc/3b18af8039e921ddf011 to your computer and use it in GitHub Desktop.
ポインタ配列を使わない普通の2次元配列arrを関数の引数で渡したときの、その関数でのarrの扱い方を確認した。
This file contains 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
void print(int *arr){ | |
int i, j; | |
for(i = 0; i < 3; i++){ | |
for(j = 0 ; j < 3; j++){ | |
printf("%d\n", arr[3*i+j]); | |
} | |
} | |
} | |
int main(){ | |
int i, j, num = 1; | |
int arr[3][3]; | |
for(i = 0; i < 3; i++){ | |
for(j = 0; j < 3; j++){ | |
arr[i][j] = num; | |
num++; | |
} | |
} | |
print(arr); | |
return 0; | |
} | |
/* | |
outputs: | |
1 | |
2 | |
3 | |
4 | |
5 | |
6 | |
7 | |
8 | |
9 | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment