A
Arun Prasath
Hi all,
I have the following question regd pointer typecasting. Is the
following type of pointer typecasting valid?
#define ALLOC(type,num) ((type *)malloc(sizeof(type)*num))
/*begin code*/
struct node{
:
} node;
typedef node *nodeptr;
node **nodeptrptr;
nodeptrptr = (nodeptr *)ALLOC(node,NUM_OF_NODES)
/*end code*/
Is the above code valid? If so, can anyone explain how it works? How
can a pointer to a memory chunk be typecast to a pointer to a pointer
to a memchunk?
Thanks,
Arun
I have the following question regd pointer typecasting. Is the
following type of pointer typecasting valid?
#define ALLOC(type,num) ((type *)malloc(sizeof(type)*num))
/*begin code*/
struct node{
:
} node;
typedef node *nodeptr;
node **nodeptrptr;
nodeptrptr = (nodeptr *)ALLOC(node,NUM_OF_NODES)
/*end code*/
Is the above code valid? If so, can anyone explain how it works? How
can a pointer to a memory chunk be typecast to a pointer to a pointer
to a memchunk?
Thanks,
Arun