M
mike79
hi all..
if I wanted to malloc a struct, say the following:
struct myStruct1
{
int number;
char *string;
}
how would I do this?
Would I need to first malloc myStruct, then malloc string?
Ive seen some malloc commands around, so are:
myStruct1 = malloc(sizeof (myStruct1));
myStruct1 = malloc(sizeof (* myStruct1));
myStruct1 = malloc(sizeof (myStruct1 *));
Can anyone tell me the difference please??
Thank you all for your help! much appreciated!
mike79
if I wanted to malloc a struct, say the following:
struct myStruct1
{
int number;
char *string;
}
how would I do this?
Would I need to first malloc myStruct, then malloc string?
Ive seen some malloc commands around, so are:
myStruct1 = malloc(sizeof (myStruct1));
myStruct1 = malloc(sizeof (* myStruct1));
myStruct1 = malloc(sizeof (myStruct1 *));
Can anyone tell me the difference please??
Thank you all for your help! much appreciated!
mike79