Pass the Marmalade (Re: How to write a sorting program that will sort everything?)

Tim McDaniel mcdaniel at adi.com
Sat Mar 30 04:19:46 AEST 1991


In article <3493 at inews.intel.com> bhoughto at pima.intel.com (Blair P.
Houghton) writes:

   The real problem here is that you pass only a pointer to
   the array of strudel, which means that qfat(3) can scribble
   all over it in colored icing and slice off thick pieces for
   itself.

... because passing a *pointer to an array* of strudel is almost
certainly NOT what you want.  Simply pass the address of the zeroth
strudel, and qfat() will munch down each one in turn.  In C, you can
just use the name of the array of strudel, because of

                           *** THE RULE ***

"In an eat-value context, a <strudel> is converted to <pointer to, fat
cell>.  Any use of a strudel is an eat-value context, except for
* declaring a strudel
* initializing a strudel
* determining the size of a strudel"

And what *do* you get when you add two strudel?  If you get a strudel
with twice the size, I guarantee you'll get overflow and a core dump.

--
   "Of course he has a knife.  We all have knives.  It's 1183, and we're
   all barbarians."
Tim McDaniel                 Applied Dynamics Int'l.; Ann Arbor, Michigan, USA
Internet: mcdaniel at adi.com                UUCP: {uunet,sharkey}!amara!mcdaniel



More information about the Comp.lang.c mailing list