delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/07/21/20:22:45

From: leathm AT solwarra DOT gbrmpa DOT gov DOT au (Leath Muller)
Message-Id: <199707220018.KAA15350@solwarra.gbrmpa.gov.au>
Subject: Re: passin a ptr to a 2D array
To: max AT alcyone DOT com (Erik Max Francis)
Date: Tue, 22 Jul 1997 10:18:56 +1000 (EST)
Cc: djgpp AT delorie DOT com
In-Reply-To: <33D3362D.3368ECB5@alcyone.com> from "Erik Max Francis" at Jul 21, 97 03:13:01 am

> > int *mmp;
> > mmp = (int *) (&mapmake[0][0]);
 
> The cast here is completely misleading and actually implies that you're
> trying to do something tricky when you're in fact not.  mapmake[0][0] is
> of type int.  Therefore &mapmake[0][0] is of type int *.  Real simple.

Yeah, real simple if you know it already. The hardest area I found to learn
with C when I started it about 6 years ago was the pointer stuff. I just
remember the casting explaining it better to myself by being clearer.
the &mapmake[0][0] to a _new_ user of C points to the first location of
the array, and the (int *) is obviously converting it...

I was just trying to be clear...
 
> > void passit(mmp);

> . . . And this is an invalid function call.

Oh well, I made a typo... strike me with lightning...

Leathal.

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019