C Programming - Pointers - Discussion
Discussion Forum : Pointers - General Questions (Q.No. 1)
1.
What is (void*)0?
Discussion:
124 comments Page 8 of 13.
Lohith said:
1 decade ago
void it self states empty or 0.
i.e mean nothing.
For void no memory location is allocated.
i.e mean nothing.
For void no memory location is allocated.
Anshul said:
1 decade ago
void *p;
/* It is a void type pointer i.e it can point too any object either int,float,etc.It means "void *p;" has certain address in the memory let take 12345.But if point to (void*)0 now it's address is 0 it means it is pointing to NULL in C.What it suggest to us is void *p is generic pointer point to any data type here (void*)0 is null pointer i.e it always point to NULL. */
summary..
void *ptr;// Address:12345
void *ptr=(void*)0; //Address:0
/* It is a void type pointer i.e it can point too any object either int,float,etc.It means "void *p;" has certain address in the memory let take 12345.But if point to (void*)0 now it's address is 0 it means it is pointing to NULL in C.What it suggest to us is void *p is generic pointer point to any data type here (void*)0 is null pointer i.e it always point to NULL. */
summary..
void *ptr;// Address:12345
void *ptr=(void*)0; //Address:0
Harsh said:
1 decade ago
NULL pointer can be portably expressed as the integer value 0 converted implicitly or explicitly to the type void*.
DNY said:
1 decade ago
Dear friend (void *) is very imp pointer that c allow us to keep any type data under it.
I simply mean that if we want store adds of int I=10;
Into any pointer we required int *.
But when we use void pointer mean it can hold adds of any type of variable.
Int I=10;
Void * vptr=&I;
Now ans of above question:
When we assign 0 value to any pointer simply it mean it pointing to 0000 location of memory.
It mean it is not pointing to any variable so it is NULL pointer.
I simply mean that if we want store adds of int I=10;
Into any pointer we required int *.
But when we use void pointer mean it can hold adds of any type of variable.
Int I=10;
Void * vptr=&I;
Now ans of above question:
When we assign 0 value to any pointer simply it mean it pointing to 0000 location of memory.
It mean it is not pointing to any variable so it is NULL pointer.
Dhara said:
1 decade ago
What is difference between null pointer and generic pointer?
Sandeep rao said:
1 decade ago
It is pointer which return nothing or null. It is use in those function which simply print something.
Swetha said:
1 decade ago
If the zero is not indicate it returns null value only.
Kintali Prasanti said:
1 decade ago
Hi all,
As of I know this is the explanation.
Void pointer is a type of pointer which can store any type of value and null pointer is a pointer which does not point to anything. So here it is mentioned as "(void*)0" means we are declaring a void pointer holding 0 as its value which is an indirect representation of null pointer.
Thanks,
As of I know this is the explanation.
Void pointer is a type of pointer which can store any type of value and null pointer is a pointer which does not point to anything. So here it is mentioned as "(void*)0" means we are declaring a void pointer holding 0 as its value which is an indirect representation of null pointer.
Thanks,
Dhiraj said:
1 decade ago
The void Type:
The void type specifies that no value is available. It is used in three kinds of situations:
S.N. Types and Description:
1. Function returns as void
There are various functions in C who do not return value or you can say they return void. A function with no return value has the return type as void. For example void exit (int status);
2. Function arguments as void
There are various functions in C who do not accept any parameter. A function with no parameter can accept as a void. For example int rand(void);
3. Pointers to void
A pointer of type void * represents the address of an object, but not its type. For example a memory allocation function void *malloc( size_t size ); returns a pointer to void which can be casted to any data type.
The void type specifies that no value is available. It is used in three kinds of situations:
S.N. Types and Description:
1. Function returns as void
There are various functions in C who do not return value or you can say they return void. A function with no return value has the return type as void. For example void exit (int status);
2. Function arguments as void
There are various functions in C who do not accept any parameter. A function with no parameter can accept as a void. For example int rand(void);
3. Pointers to void
A pointer of type void * represents the address of an object, but not its type. For example a memory allocation function void *malloc( size_t size ); returns a pointer to void which can be casted to any data type.
Vikram.s said:
1 decade ago
You can use the 0(zero) at the NULL, but in the program you may have the value 0(zero) which is required for the program, to differentiate that in <stdio.h> or <stddef.h> they have predefined this NULL as macro with,
#define NULL (void*)0.
Just to avoid the confusions of the value 0(zero), is value zero or NULL pointer.
#define NULL (void*)0.
Just to avoid the confusions of the value 0(zero), is value zero or NULL pointer.
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers