ssss <sh***@wsu.edu> wrote:
I need pass a double-type two-dimension array to a function, I can not
figure out,please help.
#include <stdio.h>
#include <stdlib.h>
#define ROWS 31
#define COLUMNS 42
void gets_passed_2d_array( double x[ ][ COLUMNS ],
size_t nrows, size_t ncols );
int main( void )
{
double a[ ROWS ][ COLUMNS ];
size_t i, j;
for ( i = 0; i < ROWS; i++ )
for ( j = 0; j < COLUMNS; j++ )
a[ i ][ j ] = i * COLUMNS + j;
gets_passed_2d_array( a, ROWS, COLUMNS );
return EXIT_SUCCESS;
}
void gets_passed_2d_array( double x[ ][ COLUMNS ],
size_t nrows, size_t ncols )
{
size_t i, j;
for ( i = 0; i < nrows; i++ )
for ( j = 0; j < ncols; j++ )
printf( "x[ %lu ][ %lu ] = %f\n", ( unsigned long ) i,
( unsigned long ) j, x[ i ][ j ] );
}
Or what exactly are you looking for?
Regards, Jens
--
\ Jens Thoms Toerring ___
Je***********@physik.fu-berlin.de
\__________________________
http://www.toerring.de