Hello!
I recently bought the book "Algorithms with C". At the very beginning of the book, I find the following code example:
I read somewhere that casting malloc is generally a very bad idea. Is this an exception to the rule? I won't invest time in this book if it turns out that it starts with a bad mistake.Code:#include <stdio.h> int g(int **iptr) { if ((*iptr = (int *)malloc(sizeof(int))) == NULL) return -1; return 0; }
Thank you for any input!