Why is p turning out const, instead of the characters pointed to?
C Interview Questions and Answers
(Continued from previous question...)
Why is p turning out const, instead of the characters pointed to?
Q: I've got the declarations
typedef char *charp;
const charp p;
Why is p turning out const, instead of the characters pointed to?
A: typedef substitutions are not purely textual.In the declaration
const charp p;
p is const for the same reason that const int i declares i as const. The typedef'ed declaration of p does not ``look inside'' the typedef to see that there is a pointer involved.
(Continued on next question...)
Other Interview Questions
|