jeudi 26 février 2015

Difference between different ways of malloc




struct node{
int w;
int x;
}
struct node *item;



  1. Please explain the difference between these statements.


  2. i read as typecasting after malloc is not needed. why is that so?


    1) item = malloc(sizeof(*item));


    2) item = malloc(sizeof(struct node));


    3) item = (struct node *) malloc(sizeof(struct node));






Aucun commentaire:

Enregistrer un commentaire