Open In App
Related Articles

C | Pointer Basics | Question 8

Improve Article
Improve
Save Article
Save
Like Article
Like

C




int main()
{
 char *ptr = \"GeeksQuiz\";
 printf(\"%c", *&*&*ptr);
 return 0;
}


(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", *&*&ptr);
 return 0;
}


Quiz of this Question
Please comment below if you find anything wrong in the above post

Whether you're preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape, GeeksforGeeks Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we've already empowered, and we're here to do the same for you. Don't miss out - check it out now!

Last Updated : 28 Jun, 2021
Like Article
Save Article
Similar Reads