← Quiz: C Pointers: all 10 questions
Quiz: C Pointers · Question 9 of 10
With const int p = &x;, what is allowed?
With const int *p = &x;, what is allowed?
- A.*p = 5; (changing x through p)
- B.p = &y; (pointing p at another int)
- C.Neither
- D.Both
Answer & explanation
Correct answer: p = &y; (pointing p at another int)
const before the * protects the value pointed to, not the pointer; int *const p is the opposite.
Can you get the rest right without peeking?
Take the timed Quiz: C Pointers quiz free. Pass it to earn XP and count towards your certificate.
Start the quiz →