2

I'm learning about dynamics data structure e.g. malloc function. Why sometimes programmers use void* as a pointer parameter to (for example) dynamic variables of integers and chars? What are the differences? What are the advantages?

user1
  • 3,893
  • 7
  • 31
  • 63
mon
  • 542
  • 1
  • 5
  • 13
  • @user1 Unclear questions that demonstrate no research effort are not worth the time spent editing them. They end up closed anyway. – Pascal Cuoq Oct 16 '15 at 05:05

1 Answers1

5

Every pointer type can be cast to void* safely. Generic functions that need to work with pointers of all sorts of objects, such as malloc and realloc can work only if they use void* in their interface.

R Sahu
  • 200,579
  • 13
  • 144
  • 260