数组指针
1. int (*p)[5];
2. //解释:p先和*结合,说明p是一个指针变量,然后指着指向的是一个为5格大小的整型数组.
3. //所以p是一个指针,指向一个数组.
4. //所以叫:组指针.
1. #include
2. int main()
3. {
4. int arr[10] = {1,2,3,4,5,6,7,8,9,0};
5. int (*p)[10] = &arr;
6. return 0;
7. }
1. #include
2. void arr1(int arr[3][5], int a, int b)
3. {
4. int i = 0;
5. for (i = 0; i < a; i )
6. {
7. int j;
8. for (j = 0; j < b; j )
9. {
10. printf("%d ", arr[i][j]);
11. }
12. printf("\n");
13. }
14. }
15. int main()
16. {
17. int arr[3][5] = { 1,2,3,4,5,6,7,8,9,10 };
18. arr1(arr, 3, 5);
19. return 0;
20. }
1. #include
2. void arr2(int(*arr)[5], int a, int b)
3. {
4. int i = 0;
5. for (i = 0; i < a; i )
6. {
7. int j;
8. for (j = 0; j < b; j )
9. {
10. printf("%d ", arr[i][j]);
11. }
12. printf("\n");
13. }
14. }
15. int main()
16. {
17. int arr[3][5] = { 1,2,3,4,5,6,7,8,9,10 };
18. arr2(arr, 3, 5);
19. return 0;
20. }
" width="16" class="ne-image-loading-icon">
请后发表内容
1个评论