Brain Teaser

Ken Buck buck at granite.cr.bull.com
Thu Mar 29 05:41:54 AEST 1990


In article <99 at demott.COM> kdq at demott.COM (Kevin D. Quitt) writes:
   [re: the 'swap()' brain teaser]
>    Disclaimer: This assumes that pointers are not longer than longs (or
>some other defined type).  On the other hand, how many machines do you
>know that have longer addresses than data? 

Hate to rain on your parade, but machines which don't implement byte
addressing will cause you problems!  In these cases, char pointers are
implemented as a word address (typically 32 bits) plus a byte offset (perhaps
16 bits), hence we have a pointer type which is bigger than a long.
Trust me - these things exist!   :-)
(Of course, this is not meant to dampen the spirits of ingenious
problem-solving - just realize that your solution is not portable...)



More information about the Comp.lang.c mailing list