Path: utzoo!utgpu!watmath!att!cbnewsl!dfp From: dfp@cbnewsl.ATT.COM (david.f.prosser) Newsgroups: comp.std.c Subject: Re: Initialisation of unsigned strings Keywords: unsigned char, initialisation, standard Message-ID: <1281@cbnewsl.ATT.COM> Date: 28 Jul 89 12:36:37 GMT References: <438@mjolner.tele.nokia.fi> Reply-To: dfp@cbnewsl.ATT.COM (david.f.prosser) Organization: AT&T Bell Laboratories Lines: 30 In article <438@mjolner.tele.nokia.fi> eru@tnvsu1.tele.nokia.fi () writes: >Thus it appears that those who want to program in pure ANSI-C without the >fuzziness introduced by the implementation-dependent behaviour of plain char >lose the convenience of string literals. This ought to be changed in the >next version of the standard (if there ever is one). Prior art exists: >all the C-compilers with unsigned char that I have used compile this usage >of string literals. The pANS requires that arrays of any of the three char types can be initialized with a string literal. The definition of *character type* can be found in section 3.1.2.5 (like most of the other mumble types): The three types char, signed char, and unsigned char are collectively called the character types. However, one cannot initialize a pointer to a signed or unsigned char with a string literal (without a cast). char ca[] = "abc"; /* valid */ signed sca[] = "abc"; /* valid */ unsigned uca[] = "abc"; /* valid */ char *cp = "abc"; /* valid */ signed char *scp = "abc"; /* invalid */ unsigned char *ucp = "abc"; /* invalid */ signed char *p = (signed char *)"abc"; /* valid */ unsigned char *p = (unsigned char *)"abc"; /* valid */ Dave Prosser ...not an official X3J11 answer...