Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!sdd.hp.com!elroy.jpl.nasa.gov!ames!uhccux!munnari.oz.au!metro!cluster!necisa!boyd From: boyd@necisa.ho.necisa.oz (Boyd Roberts) Newsgroups: comp.lang.c Subject: Re: Finding Available Length Of Strings... Message-ID: <1946@necisa.ho.necisa.oz> Date: 20 Nov 90 03:54:29 GMT References: <16758@hydra.gatech.EDU> <1990Nov09.183957.15122@dirtydog.ima.isc.com> <1990Nov13.140527.14797@ssd.kodak.com> <1990Nov17.070228.29295@sq.sq.com> Organization: NEC Information Systems Australia Pty. Ltd. Lines: 27 In article <1990Nov17.070228.29295@sq.sq.com> msb@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@necisa.ho.necisa.oz.au ``When the going gets wierd, the weird turn pro...'' * Snarfed off the net at some stage.