C Programming - Pointers - Discussion
Discussion Forum : Pointers - General Questions (Q.No. 1)
1.
What is (void*)0?
Discussion:
124 comments Page 4 of 13.
Dhanalakshmi said:
1 decade ago
#define NULL ((void*)0)
The advantage of using a void* for information hiding is more obvious when the object type is a structure. In that case, use of the void* prevents the user from accessing the structure members directly.
The advantage of using a void* for information hiding is more obvious when the object type is a structure. In that case, use of the void* prevents the user from accessing the structure members directly.
Uttam said:
1 decade ago
Void pointer or generic pointer is a pointer that can be pointed to any datatype.
Hence while declaration it doesn't point to any datatype
it is called as Null pointer.
eg.
main()
{
int *p;
void *vp;
vp=p;
}
Hence while declaration it doesn't point to any datatype
it is called as Null pointer.
eg.
main()
{
int *p;
void *vp;
vp=p;
}
Yogen raja said:
1 decade ago
The void pointer is pointer in which we can store the address of any type of variable i.e malloc() always returns void pointer because that function never knows that to which type we are allocating memory dynamically.
Georgekutty said:
1 decade ago
The actually thing is void means empty data type.
It pointers to variable but compiler don't know the type of data pointer points to. But it stores the address of it.
If it point to zero or NULL it is NULL pointer.
It pointers to variable but compiler don't know the type of data pointer points to. But it stores the address of it.
If it point to zero or NULL it is NULL pointer.
Xyz said:
1 decade ago
(void*)0
This is the definition for VOID pointer. we can assign this to any data type.
Example:
#include<stdio.h>
int main()
{
int a;
a=(void*)0;
printf("%d",a);
return 0;
}
This is the definition for VOID pointer. we can assign this to any data type.
Example:
#include<stdio.h>
int main()
{
int a;
a=(void*)0;
printf("%d",a);
return 0;
}
Partha said:
1 decade ago
Void pointer is a pointer that can point to any type of data. Null pointer is a pointer that shows that the pointer doesnt point to any valid data.
According to me this is both a void and a null pointer.
According to me this is both a void and a null pointer.
Jiten said:
1 decade ago
I think void is the correct answer because void means no return type, but we know pointer should indicates address of the data type, but no return datatype are here. So (void*) indicates the NULL pointer.
Veena kumari said:
9 years ago
'Null Pointer' means which reference nothing (means it doesn't point any address) and void pointer mean we can store any type of value's address (like address of the variable int, char, float, etc.).
Abhishek Srivastava said:
1 decade ago
Its quite an interesting question!!
VOID POINTER points no specific datatype.
NULL POINTER is a pointer of any data type with a NULL value to it, i.e it currently holds to no memory reference.
VOID POINTER points no specific datatype.
NULL POINTER is a pointer of any data type with a NULL value to it, i.e it currently holds to no memory reference.
AmolRaje Lendave said:
1 decade ago
Void pointer is a pointer which is used to point any type of variable..
0 is used to indicate that this pointer does't have any address means it is NULL. Thats why first option is correct.
0 is used to indicate that this pointer does't have any address means it is NULL. Thats why first option is correct.
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers