Hi all,
suppose i am having a structure as follows
typedef struct node
{
int n;
struct node * next;
}sn;
sn *p;
now which of the following is the correct way to allocate memory and
why ?
OR
what is the trade off between the following two allocations
1) p = malloc( sizeof(sn) );
2) p = malloc( sizeof(*p) );
suppose i am having a structure as follows
typedef struct node
{
int n;
struct node * next;
}sn;
sn *p;
now which of the following is the correct way to allocate memory and
why ?
OR
what is the trade off between the following two allocations
1) p = malloc( sizeof(sn) );
2) p = malloc( sizeof(*p) );
Comment