Results 1 to 6 of 6

Thread: Differentiation between void pointer and null pointer

  1. #1
    Join Date
    Dec 2009
    Posts
    38

    Differentiation between void pointer and null pointer

    Hi Friend,

    I am new to the programming. I have one confusion about the pointer concept. I am aware about the to type of pointer 'i.e void pointers and Null pointers. I don't know what is exact difference between the Null pointers and Void pointers. It's important for me to solve this confusion to understand the pointers concept. Is anyone knows the differentiation between void pointer and null pointer? If yes then please let me know that.

  2. #2
    Join Date
    Apr 2008
    Posts
    1,948

    Re: Differentiation between void pointer and null pointer

    Void Pointer :
    Void Pointer is a pointer which points to the specific location of memory which is of it's own type. This pointer is firstly introduced by 'ANSI'.

    Null Pointer:
    Null Pointer is a pointer which doesn't point to any location of memory. A null pointer always has zero value.

  3. #3
    Join Date
    May 2008
    Posts
    2,012

    Re: Differentiation between void pointer and null pointer

    Hi friend,

    The Void pointers are defined using the keyword 'Void'. The Void Pointer is a special type of pointer which is used by programmer to point to data type. There are so many limitation of using 'void pointers'. You can not dereferenced void pointers in the identical manner. You need to use the type-casting concept to convert the void pointers to other datatype. Following is the syntax for Void pointer:
    void* pointerVariableName;

  4. #4
    Join Date
    Apr 2008
    Posts
    2,005

    Re: Differentiation between void pointer and null pointer

    Hi,

    The Null pointer is entirely different from the void pointer concepr. Null pointer is basically any value to the data type as zero. This shows that null pointers doesn't points to any address of memory. Below is the example of the null pointer:

    int* exforsys1;
    exforsys1=0;
    In above example the 'exforsys1' pointers doesn't points to the any memory location.

  5. #5
    Join Date
    May 2008
    Posts
    2,297

    Re: Differentiation between void pointer and null pointer

    Refer below example of Void pointers, in which I have defined 'data1' as a void pointer. This 'data1' void pointers points to the memory location.
    #include <iostream>

    using namespace std;

    void increase1 (void* data1, int psize1)
    {
    if ( psize1 == sizeof(char1) )
    { char* pchar; pchar=(char*)data; ++(*pchar); }
    else if (psize1 == sizeof(int) )
    { int* pint1;
    pint=(int*)data; ++(*pint); }

    }

    int main ()
    {
    char a1 = 'x1';
    int b1 = 1602;
    increase (&a1,sizeof(a1));
    increase (&b1,sizeof(b1));
    cout << a1 << ", " << b1 << endl;
    return 0;
    }

  6. #6
    Join Date
    Oct 2005
    Posts
    2,393

    Re: Differentiation between void pointer and null pointer

    • A Void pointer is a type of pointer of void , which represent that it point to data type.
    • Null pointers is a pointer that doesn't represent any address of memory.
    • Null pointer is different pointer from a pointer which is not initialized.
    • void pointer de-referencing is not permissible.
    • programmer need to change the pointer type to void as other type of pointer to the datatype which is valid(e.g int, float, char).

Similar Threads

  1. Dereferencing NULL pointer in C++
    By TO-Phir in forum Software Development
    Replies: 4
    Last Post: 26-06-2011, 07:42 PM
  2. Changing Stylus pointer to normal Pointer in Tablet PC
    By Kelley in forum Portable Devices
    Replies: 3
    Last Post: 21-06-2011, 07:22 PM
  3. Null pointer error in java
    By Elizabeth Allen in forum Software Development
    Replies: 5
    Last Post: 19-03-2010, 02:26 PM
  4. How to use void pointer to generate 2D Array in c++
    By Conraad in forum Software Development
    Replies: 4
    Last Post: 06-02-2010, 05:14 PM
  5. Don't know about void pointer
    By Sarfaraj Khan in forum Software Development
    Replies: 5
    Last Post: 04-02-2010, 01:39 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,713,413,804.22196 seconds with 17 queries