-9

could anyone explain me please what does this piece of code mean?

  int **d= (int**)malloc((m+1)*sizeof(int));

What are those ** for the d and the (int) ? Are they someway related to pointers?

tonix
  • 6,671
  • 13
  • 75
  • 136

1 Answers1

3
int** d; //pointer to a pointer to an integer
Haris
  • 12,120
  • 6
  • 43
  • 70
  • And what about (int**) before the malloc call? – tonix Sep 13 '14 at 09:13
  • the malloc call returns the pointer to the allocated address.. to cast it into a pointer to pointer to integer, that call is used. that is type casting. – Haris Sep 13 '14 at 09:19
  • Note that in C the cast is both redundant and potentially dangerous. See: http://stackoverflow.com/questions/605845/do-i-cast-the-result-of-malloc – Paul R Sep 13 '14 at 09:28
  • 1
    @paul. ook, got what you saying. didnt know this. :) – Haris Sep 13 '14 at 09:41