Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Posting-Version: version B 2.10.2 9/18/84; site brl-tgr.ARPA
Path: utzoo!watmath!clyde!burl!ulysses!allegra!mit-eddie!godot!harvard!seismo!brl-tgr!tgr!cottrell@nbs-vms.ARPA
From: cottrell@nbs-vms.ARPA
Newsgroups: net.lang.c
Subject: multidimensional arrays
Message-ID: <7227@brl-tgr.ARPA>
Date: Fri, 11-Jan-85 11:39:44 EST
Article-I.D.: brl-tgr.7227
Posted: Fri Jan 11 11:39:44 1985
Date-Received: Sun, 13-Jan-85 08:21:59 EST
Sender: news@brl-tgr.ARPA
Organization: Ballistic Research Lab
Lines: 33

/*
okay, so you want to specify the dimensions at runtime? try this:

#define	ROWS	some constant
#define COLS	some constant

int a[ROWS][COLS];

main()
{	func(a,3,5);
	func(a,6,4);
}

#define	A(x,y)	*(a + x*j + y)

func(a,i,j)
int a[1];
{	int p,q;
	for (p = 0; p < i; p++) 
	for (p = 0; p < i; p++) {	/* row loop */
		for (q = 0; q < j; q++){/* col loop */
			printf("%d\t",A(p,q));
		} printf("\n");
	}
}

see if that doesn't get you two dimensions for one. 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?
*/