In memory arrays are stored in row major ordering.If you dont provide the column size then the system cannot make any access to any of the location in the array. when you actually look for the value at a[4][2] what the system does is that it computes the location as (4 * column_size + 2 ) * (int size ) and then makes the reference a[ new_address ].So if you dont provide the column_size it cannot perform the above operation.Try thinking how would you go about doing that with out column_size for a[4][2] ? Not possible.
When you do int * * a , you dont need because a + 1 automatically moves to the next row without the need of column size.Here it is because the underlying implementation is pointer to pointer and it increments accordingly to the next row but not next element in the same row when you do a + 1. Let me know if im wrong anywhere in my explanation. On Wed, Aug 17, 2011 at 12:04 AM, priya ramesh < love.for.programm...@gmail.com> wrote: > Why should the column size be mandatorily passed to a function which > expects a multi dimensional array > > int arr (int marray[][5], int rows); > int arr (int marray[][], int rows, int cols); > > 1st is valid whereas second is invalid. why?? > > -- > You received this message because you are subscribed to the Google Groups > "Algorithm Geeks" group. > To post to this group, send email to algogeeks@googlegroups.com. > To unsubscribe from this group, send email to > algogeeks+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/algogeeks?hl=en. > -- regards, chinna. -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.