C Programming - Pointers - Discussion
Discussion Forum : Pointers - General Questions (Q.No. 1)
1.
What is (void*)0?
Discussion:
124 comments Page 3 of 13.
Vijay said:
1 decade ago
The void data type has no values.
Example:
int a=10; //right
void b=20;//wrong
pointer
a[address of 10]--------->10
pointer
b[address]---------> NULL (no value,no address so null)
So void is a representation of NULL.
Note: void *b; //right (no value, but we can store address)
Example:
int a=10; //right
void b=20;//wrong
pointer
a[address of 10]--------->10
pointer
b[address]---------> NULL (no value,no address so null)
So void is a representation of NULL.
Note: void *b; //right (no value, but we can store address)
Brajesh said:
1 decade ago
void* p is a generic pointer to convert any types of data like-int, float, char to use of type casting. Important think is that all types of pointer can be null.
But here is (void*)0: It means void pointer to hold the address of any location but hold null value.
But here is (void*)0: It means void pointer to hold the address of any location but hold null value.
Dinesh said:
1 decade ago
The Syntax for function definition is
return type function name(data type variable name)
but here the data type is given and the variable name is not given
and there is no return type.so,it is a null pointer.a void pointer is a pointer with return type void.
return type function name(data type variable name)
but here the data type is given and the variable name is not given
and there is no return type.so,it is a null pointer.a void pointer is a pointer with return type void.
Amol said:
1 decade ago
(void *) is nothing but generic pointer. We can convert it into any other type of pointer Eg. int pointer, float pointer, by type casting it ie we can convert void pointer into int as int(void *). This generic pointer point to memory location.
JEHO said:
1 decade ago
Void is used in 2 places.
1st void function_name (void).
1st void indicate functio type is null.
Eg int main, char main.
2nd (void) indicate no parameters in function.
3rd function of void is NULL POINTER.
NULL POINTER SYNTAX IS (VOID*).
1st void function_name (void).
1st void indicate functio type is null.
Eg int main, char main.
2nd (void) indicate no parameters in function.
3rd function of void is NULL POINTER.
NULL POINTER SYNTAX IS (VOID*).
Niklesh Raut said:
1 decade ago
It is Null Pointer because, Pointer stores the addresses of another variable but when variable type is not known then it will be (void) and to store address it is consist(*) also,so (void *) and initially it points to 0th address, Means Null.
Yeswanth said:
1 decade ago
The keyword - void - itself represents that it is null and * indicates pointer so simply it indicates null pointer.
And void* represents that a pointer having no values.
For eg. in sets void={} -it represents null set na. Like that...
And void* represents that a pointer having no values.
For eg. in sets void={} -it represents null set na. Like that...
Vinod said:
1 decade ago
The syntax of NULL pointer is:
datatype *ptrname = NULL;
or
datatype *ptrname=(datatype*)0;
So, here the question is what is " (void*)0 "..?
by the above syntax we can say that (void*)0 is represents null pointer..
datatype *ptrname = NULL;
or
datatype *ptrname=(datatype*)0;
So, here the question is what is " (void*)0 "..?
by the above syntax we can say that (void*)0 is represents null pointer..
Raj said:
8 years ago
(Void *)pointer is a pointer having no data type so it can't take implicitly data type we need to give data type explicitly.
Ie
(Void *)p
Need to give;
(int)*p
Or
(char) *p
(Void* ) have the flexibility to change the data type.
Ie
(Void *)p
Need to give;
(int)*p
Or
(char) *p
(Void* ) have the flexibility to change the data type.
Balashankar said:
1 decade ago
Case 1:
printf("value =%u",(void*)0);
output is value=0;
Case 2:
printf("value =%u",(void*)1);
output is value=1;
Here in case 1 : void pointer acts as NULL pointer.
Null pointer has zero ('\0') as address.
printf("value =%u",(void*)0);
output is value=0;
Case 2:
printf("value =%u",(void*)1);
output is value=1;
Here in case 1 : void pointer acts as NULL pointer.
Null pointer has zero ('\0') as address.
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers