A c pointer knows the types of pointers and indirectly referenced
data items at runtime
How the above statement is true ??
Can anybody Explain it
A c pointer knows the types of pointers and indirectly referenced
data items at runtime
How the above statement is true ??
Can anybody Explain it
Hello @Ramitgoel,
Ques 2:
A. Option A is wrong because we cannot perform pointers asthmatics with void pointers.
D. So, option D is also incorrect.
B. A void pointer is a pointer that has no associated data type with it. A void pointer can hold address of any type and can be typecasted to any type.
nt a = 10;
char b = ‘x’;
void *p = &a; // void pointer holds address of int ‘a’
p = &b; // void pointer holds address of char ‘b’.
We cannot use it directly.
You are required to refer them to an object of some type before using them like:
void *p = &a;
Thus, this option is also wrong.
C. A c pointer knows the types of pointers and indirectly referenced data items at runtime.
We have already discussed that a must-have a type before using it. So, it knows the type of data it can point to.
Also, the *p (referenced data item i.e. the value stored at the location pointed by it) is accessed at the time of execution or at the time, when we are using it.
Hope, this would help.
Give a like, if you are satisfied.