hardcoded constants
Tom Stockfisch
tps at chem.ucsd.edu
Thu Dec 22 09:25:16 AEST 1988
In article <1988Dec15.190331.2986 at utzoo.uucp> henry at utzoo.uucp (Henry Spencer) writes:
> foo = malloc(strlen(a)+strlen(b)+2); /* 2 for '/' '\0' */
>Now, what's a good name for that "2", and how does naming it improve
>readability?
In this case I usually write
foo = malloc( strlen(a) + strlen(b) + sizeof("/") );
What do you think of that?
--
|| Tom Stockfisch, UCSD Chemistry tps at chem.ucsd.edu
More information about the Comp.lang.c
mailing list