I found on google that If you want to dynamic alocate a 2d array in C you need to use this piece of code
int **arr = (int **)malloc(r * sizeof(int *));
I want to ask if and why is really necessary to cast the malloc to (int **). I tested without the (int **) cast and it worked just fine for me, but everywhere on the internet I found that you should use the cast and I don't understand why. Thanks