Guillaume De Smedt

Dynamic pointers

Discussion created by Guillaume De Smedt on Nov 4, 2009
Latest reply on Nov 4, 2009 by Daniel Lundin

Hey all,

 

I come from a C++ computer programming background and would like to create a dynamic structure to save my data in. It needs to be dynamic as could have several a's in one info structure or only 1 a in several info structures... you get the idea.

 

ok.. here's example...

 

typedef struct
{
    int *a;

       
}info_struct;
info_struct *info;

 

now normally i'd simply say... "new info" and tadaa would have another struct to access... but this being limited language.. don't have that option.. or at least not part of my header info.

 

SO.. can anybody out there help me with this please... I'd like to eventually access the information in the followig way...

 

info[info_ptr].a[ptr];

 

or in simpler terms...

 

info[0].a[0];

 

doing it like below does work but does not make it dynamic...

 

typedef struct
{
    int a[10];

       
}info_struct;
info_struct info[10];

 

and then accessing it...  

 

 

info[info_ptr].a[ptr];

 

or in simpler terms...

 

info[0].a[0];

 

any help or explanation on what to do will be greatly appreciated... I am using a HS08 = MC9S08GT32A processor.

 

Thanks,

 

G :smileywink:

Outcomes