Path: utzoo!utgpu!attcan!uunet!husc6!purdue!decwrl!megatest!djones From: djones@megatest.UUCP (Dave Jones) Newsgroups: comp.lang.c Subject: Re: hardcoded constants Message-ID: <1113@goofy.megatest.UUCP> Date: 22 Dec 88 23:46:12 GMT References: <1797@dataio.Data-IO.COM> Organization: Megatest Corporation, San Jose, Ca Lines: 23 From article <1797@dataio.Data-IO.COM>, by bright@Data-IO.COM (Walter Bright): > In article <1104@goofy.megatest.UUCP> djones@megatest.UUCP (Dave Jones) writes: > > But doesn't sizeof('\0') return sizeof(int), instead of sizeof(char)? > Remember, the integral promotions are being done. Gack! You are correct. Due to certain intermittent reduced neurological function (sometimes I can be real dumb), it is hard for me to remember that in C, "character" constants are of type int, not char. Seems goofy to me. Can anyone suggest a rationale, so that I can remember this arcane fact? Okay. You get bucked off, you climb right back in the saddle, right? How about, foo = malloc( strlen(s) + strlen(t) + sizeof((char)'\0'));