[Coco] Ambiguous code

Bill Barnes da3m0n_slay3r at yahoo.com
Thu Sep 25 12:59:21 EDT 2008


This code looks like a simple checksum, no CRC, nothing fancy but a full sum of every value stored in a string [OK, an Array of characters] or a partial string as the pointer could be in the middle of an arry, while count specifies how much to read in and add (whole, part, even potentially past the end). 

since it is just one function of I don't know how many, I'm not sure of its application in the broader scope. (Drivewire?)


> > This sample code you provide for the checksum
> calculation is  
> > ambiguous:
> >
> > int calChecksum(char *ptr, int count)
> > {
> >     short Checksum = 0;
> >     while(--count)
> >     {
> >          Checksum += *(ptr++);
> >     }
> >     return (Checksum);
> > }



      



More information about the Coco mailing list