Path: utzoo!attcan!uunet!ogicse!ucsd!ucbvax!galileo.berkeley.edu!jbuck From: jbuck@galileo.berkeley.edu (Joe Buck) Newsgroups: comp.std.c++ Subject: Re: character array initialization Message-ID: <39503@ucbvax.BERKELEY.EDU> Date: 10 Nov 90 20:56:44 GMT References: <58962@microsoft.UUCP> Sender: usenet@ucbvax.BERKELEY.EDU Reply-To: jbuck@galileo.berkeley.edu (Joe Buck) Lines: 21 In article <58962@microsoft.UUCP>, petergo@microsoft.UUCP (Peter GOLDE) writes: > In section 8.4.2, the C++ standard disallows the legal ANSI C > initialization: > > char cv[4] = "asdf"; I just checked out that section. Gack! Why the hell did Stroustrup do that? The rationale is that the string "asdf" really has five characters (trailing null), but the meaning is obvious and ANSI C allows it. Ellis and Stroustrup's commentary says (p. 153): In this, C++ differs from ANSI C, where the example is allowed and is intended to be a convenience to the programmer. What possible rationale is there for this change? -- Joe Buck jbuck@galileo.berkeley.edu {uunet,ucbvax}!galileo.berkeley.edu!jbuck