Finding Available Length Of Strings...

Boyd Roberts boyd at necisa.ho.necisa.oz
Tue Nov 20 14:54:29 AEST 1990


In article <1990Nov17.070228.29295 at sq.sq.com> msb at sq.sq.com (Mark Brader) writes:
>It generally seems to me to produce clearer code if the constant that
>one defines specifies, not the length of the buffer (as above), but
>the maximum length of the string contained in it.  That is:
>
>	char name[MAX_LEN+1];		/* +1 for '\0' */

Ever written any Pascal?  Therein lies madness.

All these fixed length character strings are a poor man's solution.
Dynamic structures aren't that hard to code up, and once you have
the right library routines it's trivial to use them with future code.
Code them once, use them everywhere.

Only today, did my mail user agent trash the RFC 822 address parser
because it [the parser*] decided that lines _never_ exceeded 256
characters.  My user agent says lines are long as you've got virtual
memory for.  So it's time to persuade the parser about dynamics.

Should be easy.


Boyd Roberts			boyd at necisa.ho.necisa.oz.au

``When the going gets wierd, the weird turn pro...''

* Snarfed off the net at some stage.



More information about the Comp.lang.c mailing list