prev up next   top/contents search

comp.lang.c FAQ list · Question 11.11

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. (This is one of the advantages of typedefs; see question 1.13.) 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.

Additional links: further reading

References: H&S Sec. 4.4.4 pp. 81-2

prev up next   contents search
about this FAQ list   about eskimo   search   feedback   copyright

Hosted by Eskimo North