代码:
#include <stdio.h> #include <stdlib.h> #define L1 5 #define L2 3 // 数组元素是顺序存储的 int main(void) { int arr1[L1] = { 1, 2, 3, 4, 5, }; // 输出一维数组各个元素的地址 for (size_t i = 0; i < L1; ++i) { printf("%17p", &arr1[i]); } printf("\n\n"); int arr2[L1][L2] = { { 1, 2, 3 }, { 4, 5, 6 }, { 7, 8, 9 }, { 10, 11, 12 }, { 13, 14, 15 }, }; for (size_t i = 0; i < L1; ++i) { for (size_t j = 0; j < L2; ++j) { printf("%17p", &arr2[i][j]); } printf("\n"); } return EXIT_SUCCESS; }
输出:
000000000022FE20 000000000022FE24 000000000022FE28 000000000022FE2C 000000000022FE30 000000000022FDE0 000000000022FDE4 000000000022FDE8 000000000022FDEC 000000000022FDF0 000000000022FDF4 000000000022FDF8 000000000022FDFC 000000000022FE00 000000000022FE04 000000000022FE08 000000000022FE0C 000000000022FE10 000000000022FE14 000000000022FE18
时间: 2024-10-19 03:52:17