Re: nested structures and initialization
- From: Keith Willis <me@xxxxxxxxxxx>
- Date: Wed, 31 Oct 2007 09:44:46 +0000
On Wed, 31 Oct 2007 09:18:29 -0000, Sheldon <shejo284@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
.
- Follow-Ups:
- Re: nested structures and initialization
- From: Sheldon
- Re: nested structures and initialization
- References:
- nested structures and initialization
- From: Sheldon
- nested structures and initialization
- Prev by Date: nested structures and initialization
- Next by Date: Re: printf("%d",float)
- Previous by thread: nested structures and initialization
- Next by thread: Re: nested structures and initialization
- Index(es):
Relevant Pages
|