hardcoded constants
Dave Jones
djones at megatest.UUCP
Wed Dec 21 07:53:17 AEST 1988
>From article <2636 at m2-net.UUCP>, by remmers at m-net.UUCP (John H. Remmers):
...
> The space requirement for a string concatenation is a frequently-needed
> value; it's worth having a macro to represent it:
>
> #define Catspace(s,t) (strlen(s) + strlen(t) + 1)
>
You are a candidate for SLMA (Silly Little Macros Anonymous).
There are no dues. Just get a sponsor and come to the meetings.
Take it One Day At A Time, and soon you will no longer be
sending innocent programmers poking through .h files in order
to figure out what "Catspace" means.
:-), in case you didn't guess.
But if you don't like the naked "1", how about this?
foo = malloc( strlen(s) + strlen(t) + sizeof('\0'));
Tells it all. And keeps the reader on track, not grepping around
for macros.
More information about the Comp.lang.c
mailing list