Q:

What is the advantage of a void pointer in C?

0

What is the advantage of a void pointer in C?

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

Answer:

There are following advantages of a void pointer in c.

  • Using the void pointer we can create a generic function that can take arguments of any data type. The memcpy and memmove library function are the best examples of the generic function, using these functions we can copy the data from the source to destination.
  • We know that void pointer can be converted to another data type that is the reason malloc, calloc or realloc library function return void *. Due to the void * these functions are used to allocate memory to any data type.
  • Using the void * we can create a generic linked list. For more information see this link: How to create generic Link List.

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Embedded C interview questions and answers (2022)

This question belongs to these collections

Similar questions


need a help?


find thousands of online teachers now
What are dangling pointers?... >>
<< What is void or generic pointers in C?...