Modern Electronics (was Re: List charter mods & headcount... ;

From: Sean 'Captain Napalm' Conner <spc_at_conman.org>
Date: Wed Jun 23 23:51:53 2004

It was thus said that the Great der Mouse once stated:
>
> > The code would be better written as:
> [compressed again -dM]
> > #include <limits.h>
> > void foo(char *s)
> > { size_t charcount[-CHAR_MIN + CHAR_MAX];
> > memset(charcount,0,sizeof(charcount));
> > for ( ; *s ; s++) charcount[*s + -CHAR_MIN]++; }
>
> Okay, class, now who can find the bug in _this_ version? (Yes, there
> is one.)

  Sigh. Off-by-one error in declaring the array.

  -spc (Finally found it ... X-/
Received on Wed Jun 23 2004 - 23:51:53 BST

This archive was generated by hypermail 2.3.0 : Fri Oct 10 2014 - 23:37:00 BST