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 10 of 13.

Neha said:   1 decade ago
It seems type casting, as its for pointer address following it is 0, so it is null pointer.

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.

Parveen said:   1 decade ago
i think here (void*) is just like type casting of 0 and * is used to represent 0. Hence it is null pointer

Murali said:   1 decade ago
void pointer is a generic pointer. In the sense it doesn't fall under any standard types.

A generic pointer or void pointer at address 0 is nothing but a null pointer.

Anubhuti said:   1 decade ago
It is a null pointer.

If you try this float *a = (void*)0;

printf("%u \n", a);

You will see value of a;

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.

MANISH said:   10 years ago
#include<stdio.h>
void print(int*,int*,int*,int*,int*);
int main()
{
int arr[]={97,98,99,100,101,102,103,104};
int *ptr=arr+1;

print(++ptr,ptr--,ptr,ptr++,++ptr);
return 0;
}
void print(int *a,int *b,int *c,int *d,int *e)
{
printf("%d %d %d %d %d",*a,*b,*c,*d,*e);
}


Please help my in understanding the output of the above. Each step with clear description.

Yogesh said:   10 years ago
Initially *ptr pointing to arr [1]. So that reason above answer is correct as per my knowledge.

Ganesh said:   10 years ago
Void is generic Pointer used for holding address of any data type.

Lakhan said:   9 years ago
Void pointer is pointer which has no specific data type so when we not mention any data type for this pointer. So it return us global value i.e. null.


Post your comments here:

Your comments will be displayed after verification.