Go4Expert (http://www.go4expert.com/)
-   C (http://www.go4expert.com/forums/c/)
-   -   error correction (http://www.go4expert.com/forums/error-correction-t7796/)

bashamsc 11Dec2007 11:54

error correction

#define col 3
#define row 3

void foo(int *a,int col , int row)
int i,j;
int *a[col][row];
printf(" %d\n",*a[i][j]);


int arr[col][row] = {(1,2,3),(4,5,6),(6,7,8)};



I am getting this error

parse error before numeric constant

Salem 11Dec2007 18:13

Re: error correction
> int arr[col][row] = {(1,2,3),(4,5,6),(6,7,8)};
All those ( ) should be { }

> void foo(int *a,int col , int row)
Is it your intention to "flatten" the array like this, or is it just something you figured out how to pass a 2D array into a function.

void foo ( int a[row][col], int row, int col )
would accept a true 2D array.

Also, your row and col are the same names as your #defines, so the line expands to
void foo(int *a,int 3, int 3)
Tip: All #defines should be written in upper case, like
#define ROW 3

All times are GMT +5.5. The time now is 12:19.