error correction

bashamsc's Avatar, Join Date: May 2007
#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

Last edited by shabbir; 11Dec2007 at 17:56.. Reason: Code block
Salem's Avatar, Join Date: Nov 2007
Ambitious contributor
> 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