By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,227 Members | 1,376 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,227 IT Pros & Developers. It's quick & easy.

problem with array of stucture poiners

P: 3
hi,please have a look at this program.
struct tlv
{
uint32_t tag;
uint32_t len;
char val[256];
};


struct tlv *att;

struct tlvlist
{
uint32_t msglen;
struct tlv *source[2];
struct tlv *mesgkey;
struct tlv *delim;
struct tlv *oper;
};

struct tlvlist *attlist;


please find the solution for my question.

q)how can i create the memoy for the source pointer which points to the struct tlv.there can be more than one pointer there as source[n].
where n is found at the runtime.

can any one please find the solution for this to allocate memory to this and also read the values into the variables pointed by the source.

if not possible for the dynamic one please suggest atleast for the static allocation as struct tlv* source[2].

yours sincerely,
samba
Mar 23 '07 #1
Share this Question
Share on Google+
1 Reply


sicarie
Expert Mod 2.5K+
P: 4,677
hi,please have a look at this program.
struct tlv
{
uint32_t tag;
uint32_t len;
char val[256];
};


struct tlv *att;

struct tlvlist
{
uint32_t msglen;
struct tlv *source[2];
struct tlv *mesgkey;
struct tlv *delim;
struct tlv *oper;
};

struct tlvlist *attlist;


please find the solution for my question.

q)how can i create the memoy for the source pointer which points to the struct tlv.there can be more than one pointer there as source[n].
where n is found at the runtime.

can any one please find the solution for this to allocate memory to this and also read the values into the variables pointed by the source.

if not possible for the dynamic one please suggest atleast for the static allocation as struct tlv* source[2].

yours sincerely,
samba
What have you tried on this so far?
Mar 23 '07 #2

Post your reply

Sign in to post your reply or Sign up for a free account.