syntax problem

could you please help me?
What does this mean?

 
  ( unHandleStatus & 0x01 ? 1 : 0 )

Where unHandleStatus is an unsigned int

Thanks a lot
See, for example:

http://www.cprogramming.com/reference/operators/ternary-operator.html

Or is it the single & that's puzzling you? That's a bitwise AND operator - see:

http://www.cprogramming.com/tutorial/bitwise_operators.html
Last edited on
It's just a compact way of writing an if-else statement.

See Conditional ternary operator
towards the bottom of this page:
http://www.cplusplus.com/doc/tutorial/operators/


1
2
    int x; 
    x =  ( unHandleStatus & 0x01 ? 1 : 0 );

would translate as
1
2
3
4
5
    int x;
    if (unHandleStatus & 0x01)
        x = 1;
    else
        x = 0;


See also Bitwise operators on the same page.
Topic archived. No new replies allowed.