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

Udaykiran said:   7 years ago
I can't understand this. Please explain.

Vinston said:   8 years ago
What does that * mean after void?

Divya goyal said:   8 years ago
We can't write * with an integer as *p means value at the address holded by p. So by putting *0 it never refer to any address. So answer is C only.

Neha reddy said:   8 years ago
I think parenthesis id preferred first wrt*. So the answer will be in C.

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

I agree @Arpan.

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

Naman_Shah said:   8 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.

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

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

Vishalakashi said:   8 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.


Post your comments here:

Your comments will be displayed after verification.