dimanche 22 mars 2015

Difference between (int*) calloc and just calloc?


What is the difference between:



int *array;
array = (int*) calloc(5, sizeof(int));


and



int *array;
array = calloc(5, sizeof(int));


I don't get it. Both samples work. At the university the professor explained why you need the (int*) before the calloc, but I didn't get it.


In the course was a code sample like this:



struct data{
int number;
char *name;
};
typedef struct data student;

int main(){
student **list;
list = (student*) calloc(10, sizeof(student*));

//Create structures dynamic in list
....

return 0;
}


I hope someone can explain it to me. Thank you.





Aucun commentaire:

Enregistrer un commentaire