0 0 votes What is the difference between null pointer and void pointer ?? which one is used when ? Programming in C + – Arnab Mandal 1.6k views answer comment Share Follow Print See 1 comment 1 1 comment reply pawan kumarln commented Jun 29, 2017 reply Follow flag https://stackoverflow.com/questions/3581585/whats-the-difference-between-a-null-pointer-and-a-void-pointer 0 0 replyShare Please log in or register to add a comment.
Best answer 3 3 votes Null pointers and void pointers are completely different from each other To overcome from Wild pointer ( pointer which has not been initialized to anything (not even NULL))use Null pointer. A Null Pointer is a pointer which is pointing to NULL means nothing. .Null pointer mainly used in Data structure . A void pointer is known as generic pointer, which can refer to variables of any data type.When a pointer variable is declared using keyword void – it becomes a general purpose pointer variable. Address of any variable of any data type (char, int, float etc.)can be assigned to a void pointer variable. Deepak Kumar 12 answered Jun 29, 2017 • selected Jun 29, 2017 by Arjun Deepak Kumar 12 comment Share Follow See 1 comment 1 1 comment reply Arnab Mandal commented Jun 30, 2017 reply Follow flag Awsome explanation thank you so much @Deepak kumar 0 0 replyShare Please log in or register to add a comment.
1 1 vote NULL POINTER suppose u initialise any pointer with any data type then it will create a pointer which will pointing to some memory location may be in some important part of operating system where some important instructions or information present , so if there is any changes in that location may create some big problem in running the system so to protect from these kind of problem there is use of null pointer which initialise with null address syntax: int * a= NULL; a pointing no where akankshadewangan24 answered Jun 29, 2017 akankshadewangan24 comment Share Follow See all 4 Comments 4 4 Comments reply akankshadewangan24 commented Jun 29, 2017 reply Follow flag oops forget about void pointer VOID pointer: it is a generic pointer . which is used with every kind of datatype only the thing is that u need to typcast it beforev using syntax: void *a=null; int c; char b; float m; a=(int *) &c; a=(char*) &b; a=(float *) &m; hope it help :) 1 1 replyShare Arnab Mandal commented Jun 29, 2017 reply Follow flag nice explanation ,thank you so much for this indepth insight @akashdewangan24 0 0 replyShare Arnab Mandal commented Jun 29, 2017 reply Follow flag so i can conclude in simple terms as null pointer is simple a value which is nothing but 0 whereas void pointer is a type which has the ability to point to any type of pointer (int char float ) this is the reason this void pointer is used as a generic pointer type . 1 1 replyShare akankshadewangan24 commented Jun 29, 2017 reply Follow flag Yup exactly 0 0 replyShare Please log in or register to add a comment.