char *GenerateCheckSum( char *buf, long bufLen )
{
    static char tmpBuf[ 4 ];
    long idx;
    unsigned int cks;
    for( idx = 0L, cks = 0; idx < bufLen; cks += (unsigned int)buf[ idx++ ] );
    sprintf( tmpBuf, ā€œdā€, (unsigned int)( cks % 256 ) );
    return( tmpBuf );
}

Add a code snippet to your website: www.paste.org