C Programming - Pointers - Discussion

Discussion Forum : Pointers - General Questions (Q.No. 1)
1.
What is (void*)0?
Representation of NULL pointer
Representation of void pointer
Error
None of above
Answer: Option
Explanation:
No answer description is available. Let's discuss.
Discussion:
124 comments Page 7 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)

Gowda said:   1 decade ago
( void * ) is a void pointer..means its a pointer with no specific type...Integer zero 0 has various description depending upon the context in which it is used.
Each pointer has its own NULL values.In fact NULL is #defined in stddef.h to zero value.So NULL pointer basically means pointer containing zero or referencing no where...
for example
int main()
{
int *p=NULL;
if(p==0)
printf("hello");
return 0;
}
prints hello
and we have '\0' null char which is basically a value with all bits set zero...These null pointer and null char are for the purpose programmer convinience

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.

Sumit jaiswal said:   1 decade ago
Void pointer does point any data type but null pointer does not point anywhere.

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.

Ravindra bagale said:   1 decade ago
Hello guys, '0' is not NULL. Having value '0' means having something, but NULL means - Nothing, not also Zero. Then how you says that. (void*) 0 is pointing to NULL.

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;
}

Kranthi said:   1 decade ago
The main difference between NULL pointer and Void pointer is, Null pointer doesn't represent any memory location.Its value is 0. But void pointer can represents to memory location of its own type.

In the example (Void*)0(zero). it means a pointer type void represents to the location of zero.so its NULL(as mentioned 0 in the example) so syntax for the NULL pointer can be used as (Void*)0

Ajish said:   1 decade ago
(void *) is null pointer
(void *)0 what it means?

Laxman dethe said:   1 decade ago
What is mean by 0?


Post your comments here:

Your comments will be displayed after verification.