Sunday, July 22, 2018

When do I need to cast the result of malloc in C language?

Based on this old question malloc returns a pointer to void that it




is automatically and safely promoted to any other pointer type





But reading K&R I've found this following code



char *strdup(char *s)
{
char *p;
/* make a duplicate of s */
p = (char *) malloc(strlen(s)+1)



What is the difference?

No comments:

Post a Comment

plot explanation - Why did Peaches' mom hang on the tree? - Movies & TV

In the middle of the movie Ice Age: Continental Drift Peaches' mom asked Peaches to go to sleep. Then, she hung on the tree. This parti...