<p>If I have: </p>

<pre><code>signed char * p;
</code></pre>

<p>and I do a comparison:</p>

<pre><code>if ( *p == 0xFF )
   break;
</code></pre>

<p>it will never catch 0XFF, but if I replace it with -1 it will:</p>

<pre><code>if ( *p == (signed char)0xFF )
   break;
</code></pre>

<p>How can this happen? Is it something with the sign flag? I though that <code>0xFF == -1 == 255</code>.</p>

The value
```
0xFF
```
is a signed int value. C will promote the
```
*p
```
to an
```
int
```
when doing the comparison, so the first if statement is equivalent to:
```
```
if( -1 == 255 ) break;
```
```
which is of course false. By using
```
(signed char)0xFF
```
the statement is equivalent to:
```
```
if( -1 == -1 ) break;
```
```
which works as you expect. The key point here is that the comparison is done with
```
int
```
types instead of
```
signed char
```
types.