Home TechnologyComputers Subscribe to RSS

What Is The Use Of 'Void' Pointers?

Answer Question

1 Answer - Sort by: Date | Rating

    Pointers are used in languages like C++, and Java and can be confusing for many programmers.  However, the concept behind a pointer is relatively simple.  It stores the memory address where a particular variable is stored.  We can then directly access the variable, through the memory address, to read its contents or perform other manipulations.  Thus, a variable that stores an address value is called a pointer.

    When you define a pointer it must have data type.  This is not the data type of the pointer but the data type of the kind of variable that the pointer points to. For example, if you want a pointer that stores the address of an integer then that pointer will be of int data type (pointer to an int).  Similarly, you cannot store the address of a float type variable in an int pointer.  A pointer must be of the same data type as the variable who's address it stores.

    The only exception to the above stated rule is the VOID POINTER.  A void pointer is a general-purpose pointer that can store the address of any data type.  

    Void pointers can be used to pass pointers to functions that manipulate data irrespective of the data type.
    0 0

    Rocksolid 

    answered 3 years ago

      More

      More

         
         

        Ask a Question via Twitter

        Send a question to @askblurtit and we will publish it online and send you a reply everytime you receive an answer.

        Blurtit Store

        Get T-shirts, hoodies, caps and more at the Blurtit store

        Blurtit International