C | Pointer Basics | Question 8
int main() { char *ptr = "GeeksQuiz"; printf("%c\n", *&*&*ptr); return 0; } |
chevron_right
filter_none
(A) Compiler Error
(B) Garbage Value
(C) Runtime Error
(D) G
Answer: (D)
Explanation: The operator * is used for dereferencing and the operator & is used to get the address. These operators cancel out effect of each other when used one after another. We can apply them alternatively any no. of times. In the above code, ptr is a pointer to first character of string g. *ptr gives us g, &*ptr gives address of g, *&*ptr again g, &*&*ptr address of g, and finally *&*&*ptr gives ‘g’
Now try below
int main()
{
char *ptr = "GeeksQuiz";
printf("%s\n", *&*&ptr);
return 0;
}
Recommended Posts:
- C | Pointer Basics | Question 2
- C | Pointer Basics | Question 17
- C | Pointer Basics | Question 6
- C | Pointer Basics | Question 1
- C | Pointer Basics | Question 7
- C | Pointer Basics | Question 17
- C | Pointer Basics | Question 11
- C | Pointer Basics | Question 17
- C | Pointer Basics | Question 3
- C | Pointer Basics | Question 14
- C | Pointer Basics | Question 13
- C | Pointer Basics | Question 16
- C | Pointer Basics | Question 15
- C | Pointer Basics | Question 10
- C | Pointer Basics | Question 12



