You have many options

Particle *p = createParticle();

So to access to X and Y element you can access with index = y*Width + x

Or you can use an unitary array of arrays (yes, an multidimensional array is
this, an array of arrays).

Particle **p = createParticle();

so, to access to X and Y, you use p[y][x] (to low level C, is the same that
use index=y*WIDTH + x, but in this case, the WIDTH is provide by the
compiler).

p[y] is the Y-array of elements with WIDTH elements. to access to an
element...
p[y][x].

Particle p[HEIGHT][WIDTH];
createParticle(p);

Saludos

2009/11/5 Sam <[email protected]>

>
>
> Hey all
> so yes basically the subject title gives it away really. Im just creating a
> multidimensional array made up of my own particle structure using visual
> studio c++ 2008
>
> Particle myParticles[ROWS][COLS];
> i then continue to fill in all the info i need to this array
> but how do i return it back to my main code without causing errors and
> memory leaks
> i was trying
> Particle[][] CreateFlag(int size,Vector3 InitialPos){
> //fill array
>
> return &myParticles[0][0];
> }
>
> then in my main code
> Flag[0][0] = CreateFlag(size,Pos);
>
> this is all wrong im sure but thats why im here.. i was also wondering if i
> passed a pointer to a multidimensional array from my main code and just
> filled that in within the function. or is that just bad programming?
> eg
> particle myparticle[10][10];
> createflag(myparticle);
>
> void createflag(particle flag[10][10]){
> particle testflag[10][10] ;
> //fill testflag
>
> memcpy(flag,testflag, sizeof testflag);
> }
>
> any help and guidance would be much appreciated
> g
>
>  
>



-- 
--------------------------------------------------------
VISIT MY BLOG : http://ageo.blogspot.com/

picture blog : http://ageo.deviantart.com/journal/


[Non-text portions of this message have been removed]



------------------------------------

To unsubscribe, send a blank message to 
<mailto:[email protected]>.Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/c-prog/

<*> Your email settings:
    Individual Email | Traditional

<*> To change settings online go to:
    http://groups.yahoo.com/group/c-prog/join
    (Yahoo! ID required)

<*> To change settings via email:
    [email protected] 
    [email protected]

<*> To unsubscribe from this group, send an email to:
    [email protected]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/

Reply via email to