fork(3) download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main() {
  5. int array[2][3] = { { 1, 2, 3 },
  6. { 4, 5, 6 }
  7. };
  8.  
  9. // Reinterpret the array with different indices
  10. int(*array_pointer)[3][2] = reinterpret_cast<int(*)[3][2]>(array);
  11.  
  12. for (int x = 0; x < 3; ++x) {
  13. for (int y = 0; y < 2; ++y)
  14. std::cout << (*array_pointer)[x][y] << " ";
  15. std::cout << std::endl;
  16. }
  17. // Output:
  18. // 1 2
  19. // 3 4
  20. // 5 6
  21.  
  22. return 0;
  23. }
Success #stdin #stdout 0s 3340KB
stdin
Standard input is empty
stdout
1 2 
3 4 
5 6