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

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

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

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.).

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

Vishalakashi said:   9 years ago
NULL is used to indicate the pointer that doesn't point to a valid location. Ideally, we should initialize pointers as NULL if we don't know their value at the time of declaration. Also, we should make a pointer NULL when memory pointed by it is deallocated in the middle of a program.

Void pointer:it is a generic pointer that can point to any data type. We can assign any data type to void pointer and a void pointer can be assigned to a pointer of any data type.

Selvakarna said:   9 years ago
What is the scope of NULL pointer?

Selvakarna said:   9 years ago
What is the scope of NULL pointer?

Naman_Shah said:   9 years ago
A null pointer is one which is not pointing to anything, i.e. it is assigned a null value. If there is no address to assign to a pointer, it is considered a good practice to set it to null.

Syntax: <data type> *<variable name> = NULL;
Example: int *ptr = NULL;
char *ptr = '\0';

A void pointer is one which does not have any data type associated with it, i.e. it can be assigned a value of any type. Also known as the general purpose pointer.
Example: void *ptr;
int a; char c;
ptr = &a; //ptr changes to integer pointer as address of integer is assigned to it
ptr = &c; //ptr changes to character pointer as address of character is assigned to it.

Aditya dubey said:   8 years ago
I think parenthesis id preferred first wrt * so the answer will be C.

Brajesh Soni said:   8 years ago
0 may present valid address in memory.

I agree @Arpan.


Post your comments here:

Your comments will be displayed after verification.