hardcoded constants

Dave Caswell dc at gcm
Thu Dec 22 18:05:38 AEST 1988


John H. Remmers writes
>  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)


and Dave Jones rambles
.
.foo =  malloc( strlen(s) + strlen(t) + sizeof('\0'));
                                        |
					|--this is four on 32-bit machines

.Tells it all.  And keeps the reader on track, not grepping around
.for macros.

An advantage of functions or macros is what you write it once and debug it;
you cut down the chance of errors.  I wouldn't mind searching for code what
worked.

-- 
Dave Caswell (former EMU student)
Greenwich Capital Markets                             uunet!philabs!gcm!dc



More information about the Comp.lang.c mailing list