Advertisement
Guest User

2D array for Reddit

a guest
Aug 11th, 2022
32
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.49 KB | None | 0 0
  1. #include <cstdio>
  2. const int NUM_COLS=10;
  3. const int NUM_ROWS=10;
  4.  
  5. int array2d[NUM_ROWS][NUM_COLS];
  6.  
  7. int main(){
  8.     for(int row=0; row<NUM_ROWS; ++row){
  9.         for(int col=0; col<NUM_COLS; ++col){
  10.             array2d[row][col]=(row<<16)+col;
  11.         }
  12.     }
  13.     for(int row=0; row<NUM_ROWS; ++row){
  14.         for(int col=0; col<NUM_COLS; ++col){
  15.             printf("Row: %x Col: %x Address: %p Value: %x\n", row, col, &array2d[row][col], array2d[row][col]);
  16.         }
  17.     }
  18.     return 0;
  19. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement