[comp.lang.c] Type of "xxx"

worley@compass.com (Dale Worley) (06/18/91)

In article <91165.174358KQS@psuvm.psu.edu> KQS@psuvm.psu.edu (Kevin Sullivan) writes:
   second:  "9" evaluates to a (const char *), not a char.  

Sorry, the type of "9" is (char *).  The ANSI committee discovered
that too much code would break if its type was (const char *), because
you couldn't do things like:

	char *p = "abc";

(You can't assign a pointer-to-constant-T to a pointer-to-T.)  See
section 3.1.4 of the standard and rationale.

(Actually, the type of "9" is "array of 2 chars", which is almost
always immediately coerced into "pointer to char".)

Dale Worley		Compass, Inc.			worley@compass.com
--
The notion of a "record" is an obsolete remnant of the days of the
80-column card.	-- Dennis M. Ritchie