books[ctr] = (struct bookInfo*)malloc(sizeof(struct bookInfo));
I am okay with everything but why to typecast malloc() ?
2nd if we use malloc(sizeof(struct bookInfo))we have to tell the function how many bytes like malloc(10 * sizeof(int)) which means ten bytes size of an integer. What appears in my mind when I say 10 bytes like ten boxes and these boxes large enough to hold an integer, right ? But in this code
malloc(sizeof(struct bookInfo));it is not mentioned how many bytes ? what does that mean ? I hope it's clear
This post has been edited by xcool: 28 January 2014 - 10:49 AM