🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.c
Article #1089

type of string literals

#1089
From: Richard H. Gumpertz
Date: Thu, 18 Jan 1990 17:38
17 lines
1464 bytes
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 |
  ==========================================================================
Technical Details
Message-ID: <485@cpsolv.CPS.COM>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!cs.utexas.edu!uwm.edu!zaphod.mps.ohio-state.edu!lavaca.uh.edu!uhnix1!texbell!cpsolv!rhg

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!cs.utexas.edu!uwm.edu!zaphod.mps.ohio-state.edu!lavaca.uh.edu!uhnix1!texbell!cpsolv!rhg
From: rhg@cpsolv.CPS.COM (Richard H. Gumpertz)
Newsgroups: comp.std.c
Subject: type of string literals
Message-ID: <485@cpsolv.CPS.COM>
Date: 18 Jan 90 17:38:14 GMT
Reply-To: rhg@cpsolv.uucp (Richard H. Gumpertz)
Organization: Computer Problem Solving, Leawood, Kansas
Lines: 17