guitar-player

allocate_multidimencional_array.cpp

Mar 30th, 2012
44
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.44 KB | None | 0 0
  1. //http://www.codeproject.com/Articles/21909/Introduction-to-dynamic-two-dimensional-arrays-in
  2.  
  3. int **dynamicArray = 0;
  4.  
  5. //memory allocated for elements of rows.
  6.  
  7.  
  8. dynamicArray = new int *[ROWS] ;
  9.  
  10. //memory allocated for  elements of each column.
  11.  
  12.  
  13. for( int i = 0 ; i < ROWS ; i++ )
  14. dynamicArray[i] = new int[COLUMNS];
  15.  
  16. //free the allocated memory
  17.  
  18.  
  19. for( int i = 0 ; i < ROWS ; i++ )
  20. delete [] dynamicArray[i] ;
  21. delete [] dynamicArray ;
Advertisement
Add Comment
Please, Sign In to add comment