Re: nested structures and initialization
- From: Sheldon <shejo284@xxxxxxxxx>
- Date: Wed, 31 Oct 2007 10:09:45 -0000
On 31 Okt, 10:44, Keith Willis <m...@xxxxxxxxxxx> wrote:
On Wed, 31 Oct 2007 09:18:29 -0000, Sheldon <shejo...@xxxxxxxxx>
wrote:
Can anyone help with this problem with setting up nested structures
and initializing them for use.
I have created several structs and placed them in a super struct that
I will then pass to some functions. I have defined them in the
following manner:
<snip>
typedef struct super Super;
<snip>
struct super {
Transient *TR;
Satellites *Sp;
Satellites *Su;
Satellites *Au;
Satellites *Wi;
};
<snip>
Super *InitStruct(void) {
Super *sptr=NULL;
if(!(sptr=malloc(sizeof(Super)))) {
return NULL;
}
<snip remainder>
Well the first thing that leaps out is that you've allocated space for
a "struct super", which is simply five pointers. Nowhere do you
allocate the memory that those pointers point at. I'm not even going
to try and see what else is wrong :-)
--
PGP key ID 0xEB7180EC
Ok, fair enough. How would you do it then? Let's say a 3 tier struct?
Can you give an example that I can expland on?
/S
.
- References:
- nested structures and initialization
- From: Sheldon
- Re: nested structures and initialization
- From: Keith Willis
- nested structures and initialization
- Prev by Date: Re: A Trend Towards Lower Software Maintenance Budgets?
- Next by Date: Re: nested structures and initialization
- Previous by thread: Re: nested structures and initialization
- Next by thread: Re: nested structures and initialization
- Index(es):
Relevant Pages
|