CSCI 103L Lecture Notes - Lecture 8: Memory Leak, C Dynamic Memory Allocation, C String Handling
Document Summary
Multidimensional arrays: row and columns, have to give it both dimensions my_matrix[2][3], my_matrix[1][3][4] When passing as a formal parameter you must give the function all but the top dimension. When passing as an actual parameter you can still pass just the name. Ex: 3 dimensional array must pass 2. Linearization of multidimensional arrays: 2 or 3 dimensional arrays are still stored linearly, c/c++ uses a policy that lower dimensions are placed next to each other followed each by higher level dimensions. Access x[ i ][ j ]: start address + (i*3+ j)*size of int: with each step being the length of one int (or double, etc. ) Ex: declare int x[2][4][3]: access: x [ p ] [ i ] [ j ]: start address + (p*3*4 + i*4 + j) * size. Can compile multiple les into one executable le: g++ -g -o lename le. cpp le2. cpp. Use if you don"t know the size of your data until the program runs.