More Pointers ...

Ted L. Glenn tlglenn at cs.arizona.edu
Thu Mar 14 07:01:27 AEST 1991


In article <1991Mar13.161322.8214 at uunet.uu.net>, karln at uunet.uu.net writes:
> 
>   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 ???
> 
             [ Program deleted ]
> 
>    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
> 	

     When you pass an array to a function, you're passing a pointer to
the "top" of the array. In the function, you can make the array declaration
without the *. So, you have (Board)[3][3] instead of (*Board)[3][3]. The
program worked as is because you were consistent with the *.
     I mentioned that you were passing a pointer. That usually means that
the function's declaration should have a *. Arrays, however, work a little
differently. C's handling of arrays do not require the * in the function's
declaration. I can't recall right now exactly how C implement's this.....
     Anyways, your program will be fine if you replace all the (*Board)'s
with (Board).


-- 
        -Ted L. Glenn             "Don't worry, be happy!" <--Ack! Pffffhhht!
         tlglenn at cs.arizona.edu
         G19382105 at ccit.arizona.edu    G19382105 at ARIZRVAX.BITNET



More information about the Comp.lang.c mailing list