Path: utzoo!utgpu!watmath!clyde!att!westmark!mole-end!mat From: mat@mole-end.UUCP (Mark A Terribile) Newsgroups: comp.lang.c Subject: Re: hardcoded constants Summary: There is a decent way ... or two Message-ID: <124@mole-end.UUCP> Date: 18 Dec 88 21:31:37 GMT References: <1988Dec8.173158.11839@utzoo.uucp> <846@starfish.Convergent.COM> <5212@bsu-cs.UUCP> Organization: mole-end--private system. admin: mole-end!newtnews Lines: 18 > [But how about] about things like (in a function to concatenate > two strings with a '/' in between): > > foo = malloc(strlen(a)+strlen(b)+2); /* 2 for '/' '\0' */ > > You are right. This is a valid exception to my suggestion, and it had > not occurred to me. Well, there is a way, although it's a little wordy and I don't know if I'd do it myself. foo = malloc( strlen( a ) + strlen( b ) + 2 * sizeof( char ) ); You may still have to note that the chars are '/' and null. -- (This man's opinions are his own.) From mole-end Mark Terribile