Mail Archives: djgpp/2000/04/30/21:44:18
Horst Kraemer wrote:
>
> On Sun, 30 Apr 2000 05:33:32 -0400, Krogg <krogg DOT no DOT to DOT spam AT gtcom DOT net>
> wrote:
>
> > > Therefore you can't "swap" statically allocated arrays without
> > > swapping the data float by float.
>
> > I bet you can,I dont know how yet,but i am drinking "Mountian Dew" and
> > one day i will stay up long enough to prove it.
>
> I hope "Mountian Dew" isn't an insecticide...
ITs a softdrink,lots of sugar and caffeine.
[snip]
> >
> > > float x[100][50];
> > > float y[100][50];
> >
> > Is there some reason you used [100] instead of [50] as
> > the first subscript?
>
> Yes. To make explicit the the 50 in the definition of the pointer
>
> float (*p1) [50];
>
> is referring to the second dimension of the original array and not to
> the first. The first dimension is always neclected when defining a
> pointer which matches an array type.
DUH...Now i get it..
> The same for
>
> float a [10][20][30];
>
> The matching pointer type is
>
> float (*p) [20][30];
> /* "pointer to array [20][30] of float"
> "replacing array[x] of array [20][30] of float" */
> p = a;
>
> The whole story obviously works, too, for dynamically allocated arrays
>
> float (*p1) [50];
> float (*p2) [50];
>
> p1 = malloc (100 * sizeof *p1);
> p2 = malloc (100 * sizeof *p2);
>
> Now you have two "anonymous" arrays float [100][50] in free store and
> p1,p2 are pointing to their respective initial elements (which are
> arrays [50] of float).
>
By the way,after implementing this,my program is much faster,AND
importantly i have learnt a lot more that i was seeking to.
Thanks again....
--
|"""""<`.THE PRINCE ,'>"""""""""""""""""""""""""""""""""""|
| `.`/""""""\,',' my sig is too big, |
|SEE HIS ( / \ \' SEE HIS but its really cool. |
| FACE \/<> <>\/ SMILE |
| / W \ Visit my ascii art site: |
| ,'\_|||||_/`. http://www.gtcom.net/~krogg/ascii/ |
| ,',' ||| `.`. krogg DOT no DOT to DOT spam AT gtcom DOT net |
|____<,' TIME TO DIE `.>____Remove no.to.spam to reply____|
- Raw text -