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

Harshal Garg said:   9 years ago
In C, NULL is a macro.
It is defined as #define NULL 0.
So the above question can be seen as;
void *p;
p=(void *)0;
And the question is what is p?

The answer it is a 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.).

Dushyant said:   9 years ago
Void is no return type. If I write (void*) something then print the void value=null.

Ajith kumar said:   9 years ago
What is meant by pointer?

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.

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

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

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.

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.

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;


Post your comments here:

Your comments will be displayed after verification.