Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!uflorida!haven!mimsy!chris From: chris@mimsy.UUCP (Chris Torek) Newsgroups: comp.arch Subject: Re: String lengths Message-ID: <15907@mimsy.UUCP> Date: 11 Feb 89 03:58:42 GMT References: <762@atanasoff.cs.iastate.edu> <28200270@mcdurb> Organization: U of Maryland, Dept. of Computer Science, Coll. Pk., MD 20742 Lines: 22 More or less incidentally: it is easy to build counted strings out of C strings, if you prefer counts. For instance: typedef struct string { int len; char *str; } string; #define STRING(s) { sizeof(s) - 1, s } string foo = STRING("foo"); In pANS C this works for automatic variables as well as statics. These strings are not normal expressions, though, and cannot be anonymous---that is, result = some_string_function(str, STRING("lima beans")) is illegal (though gcc has an extension that will do it). -- In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 7163) Domain: chris@mimsy.umd.edu Path: uunet!mimsy!chris