fork download
  1. #include <stdio.h>
  2. #define N 4
  3.  
  4. int main(void)
  5. {
  6. int a[N][2];
  7. int (*b[N])[2];
  8. int (*c)[2];
  9. int **d;
  10. int i;
  11.  
  12. for (i = 0; i < N; i++) {
  13. a[i][0] = 2 * i + 1;
  14. a[i][1] = 2 * i + 2;
  15. }
  16. for (i = 0; i < N; i++)
  17. printf("%d, %d\n", a[i][0], a[i][1]);
  18. printf("\n");
  19.  
  20. for (i = 0; i < N; i++) {
  21. b[i] = &a[i];
  22. }
  23. printf("b = %08X\n", b);
  24. for (i = 0; i < N; i++)
  25. printf("%d, %d\n", (*b[i])[0], (*b[i])[1]);
  26. printf("\n");
  27.  
  28. c = a;
  29. for (i = 0; i < N; i++)
  30. printf("%d, %d\n", c[i][0], c[i][1]);
  31. printf("\n");
  32.  
  33. d = (int **)b;
  34. printf("d = %08X\n", d);
  35. for(i = 0; i < N; i++)
  36. printf("%d, %d\n", d[i][0], d[i][1]);
  37. printf("\n");
  38.  
  39. return 0;
  40. }
  41.  
Success #stdin #stdout 0s 1788KB
stdin
Standard input is empty
stdout
1, 2
3, 4
5, 6
7, 8

b = BFB795D0
1, 2
3, 4
5, 6
7, 8

1, 2
3, 4
5, 6
7, 8

d = BFB795D0
1, 2
3, 4
5, 6
7, 8