[comp.std.c] type of string literals

rhg@cpsolv.CPS.COM (Richard H. Gumpertz) (01/19/90)

I can't find an explicit definition in the C standard of the type of a string
literal.  That is, is it "array of char"?  The answer only matters, as best I
can tell, when used with sizeof (and maybe when passed to a function that
takes a char[10] argument).  Is sizeof("abcdefghi") 9, 9+1, or sizeof(char *)?

The best I can find is in 3.3.1: "It is an lvalue with type as detailed in
3.1.4."  The type of string literals is NOT detailed in 3.1.4; the type of
each element is detailed there.  Given that it is an lvalue, however, I
conclude that it must be the whole array, including the terminating '\0' and
so sizeof("abcdefghi") is 10.

Am I correct?  Please respond with citations to the standard, not gestalt.
-- 
  ==========================================================================
  | Richard H. Gumpertz    rhg@CPS.COM    (913) 642-1777 or (816) 891-3561 |
  | Computer Problem Solving, 8905 Mohawk Lane, Leawood, Kansas 66206-1749 |
  ==========================================================================