multidimensional arrays

Mark Brader msb at lsuc.UUCP
Sat Jan 19 09:46:13 AEST 1985


> int a[ROWS][COLS];
> #define	A(x,y)	*(a + x*j + y)
> func(a,i,j)
> int a[1];
> ....
> 			printf("%d\t",A(p,q));
> ... the only problem is
> that the address of an array element cannot be taken. to do that you need:
> 
> #define A(x,y) a[x*j + y]
> 
> hey, why didn't i just say that in the first place?

Really now, you might have tried it.  (Yes, I did.)  Of course the two are
equivalent.   By the way, wouldn't it be clearer to declare int a[]; without 1?

Mark Brader



More information about the Comp.lang.c mailing list