"jamx" <> writes:
> I need to compare the following values:
>
> char buf[3];
>
> /* buf is filled using COMport here... */
>
> if (buf[0] == 0x85) {
> /* do something */
> }
>
> But since 0x85 is bigger then char's maximum value this won't really
> work. So how can i compare all bits of a char with a other byte, like
> 0x85 in this example???
>
> I was thinking about casting the char to unsigned char, in the
> if-statement. But im not sure if that will work flawlessly...
Plain char may be either signed or unsigned. Apparently it's signed
in your environment.
Is there any reason you can't just declare buf as
unsigned char buf[3];
?
--
Keith Thompson (The_Other_Keith)
kst- <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.