marty wrote:
Flash Gordon wrote:
cr**********@gmail.com wrote:
hello,
I want a checksum function that operates on unsigned char *
string. Is there any ready function avail to me on linux?
An unsigned char * is not a string in C in the usual sense.
A char * which is terminated by '\0' is a string in C. If you want your
function to operation on an unsigned char * then you'll have to tell it how
long the sequence of bytes are.
unsigned short checkSum(unsigned char *toBeChecked, int toBeCheckedLength);
Martin
No Marty.
The definition of a C string is indeed in terms of char but there is
nothing said about whether char is signed or unsigned. This is an
implementation detail.
Alone among integer types, there are three char types: 1. char, 2.
signed char and 3. unsigned char. The first, char, is identical to one
of the other two. Which one is implementation defined.
ASCII is a 7-bit character set and all its characters will be
'non-negative' even with 'char' being 'signed char'. EBCDIC on the other
hand is an 8-bit character set. For its characters to be 'non-negative'
the implementation of 'char' must be 'unsigned char'.
--
Joe Wright mailto:jo********@comcast.net
"Everything should be made as simple as possible, but not simpler."
--- Albert Einstein ---