fork(2) download
  1. /*
  2. http://stackoverflow.com/questions/36700828/dereferencing-2d-array
  3. */
  4.  
  5. #include <iostream>
  6. #include <string>
  7.  
  8. using namespace std;
  9.  
  10. int arr[4][3]={
  11. {1,2,3},
  12. {4,5,6},
  13. {7,8,9},
  14. {10,11,12}
  15. };
  16.  
  17. int main(){
  18. cout<<"&arr = "<<&arr<<endl;
  19. cout<<" arr = "<<arr<<endl;
  20. cout<<"*arr = "<<*arr<<endl;
  21.  
  22. cout<<"*(int*)arr = "<<*(int*)arr<<endl;
  23.  
  24. int* b = (int*)arr;
  25. for(int i=0; i<4*3; i++){
  26. cout<<*b+i<<",";
  27. }
  28. }
  29.  
Success #stdin #stdout 0s 3456KB
stdin
Standard input is empty
stdout
&arr = 0x8049bc0
 arr = 0x8049bc0
*arr = 0x8049bc0
*(int*)arr = 1
1,2,3,4,5,6,7,8,9,10,11,12,