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
  • 4,031
  • 8
  • 37
  • 66
mon
  • 641
  • 1
  • 7
  • 14
  • @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
  • 204,454
  • 14
  • 159
  • 270