More Pointers ...

karln at uunet.uu.net karln at uunet.uu.net
Thu Mar 14 02:13:22 AEST 1991


  Something bothers me about this example program. I works, but
I did not think the array passing and pointers would come out looking
like this. I've tried other ways of doing this, but this seems to be
the only way I can get it to work. Is there another way ???

[---------------------------Cut Here--------------------------]
#include <stdio.h>
main()
{
	int Board[3][3];

	init_board( Board );
	
	show_board ( Board );
}
init_board ( Board )
int (*Board)[3][3];
{
	int i, j;
	for ( i=0; i < 3; ++i ) {
		for ( j=0; j<3; ++j ) {
			(*Board)[i][j] = 0;
		}
	}
}
show_board( Board )
int (*Board)[3][3];
{
	int i;
	for ( i=0; i < 3; ++i ) {
		printf("%d %d %d\n", 
			(*Board)[i][0], 
			(*Board)[i][1], 
			(*Board)[i][2] );
	}
}
[---------------------------Cut Here--------------------------]

   Specificly the use of Board seems strange. Should I be using
int **Board somewhere? I did try using them at first, but things
wouldn't work right. Anybody care to make ANY sort of comment here?

	Karl Nicholas
	karln!karln at uunet.uu.net
	



More information about the Comp.lang.c mailing list