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:
122 comments Page 2 of 13.

Divya goyal said:   7 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:   7 years ago
I think parenthesis id preferred first wrt*. So the answer will be in C.

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

I agree @Arpan.

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

Naman_Shah said:   7 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:   7 years ago
What is the scope of NULL pointer?

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

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

Harshal Garg said:   8 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:   8 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.).


Post your comments here:

Your comments will be displayed after verification.