www.thecareerplus.com
The CareerPlus
Home Technical Resources Programming Arrays and Pointers
Thursday 09th September 2010
 
 
How to write functions which accept two-dimensional arrays when the width is not known before hand?

Discuss it!          


Try something like


myfunc(&myarray[0][0], NO_OF_ROWS, NO_OF_COLUMNS);

void myfunc(int *array_pointer, int no_of_rows, int no_of_columns)
{ 
  // myarray[i][j] is accessed as array_pointer[i * no_of_columns + j] 
}


Discuss it!          

CrackTheIntervew.NET
Advertisement
 
Top! Top!