|
From: Per W. <pw...@ia...> - 2006-03-18 10:13:02
|
enum {
FLAG_A =3D 0x0001,
FLAG_B =3D 0x0002,
FLAG_C =3D 0x0004
};
unsigned flags =3D FLAG_A|FLAG_B;
=2E..
// A is set
if (flags & FLAG_A) {}
// A isn't set
if (!(flags & FLAG_A) {}
// Only A is set
if (flags =3D=3D FLAG_A) {}
// Both A and B is set
if ((flags & FLAG_A|FLAG_B) =3D=3D (FLAG_A|FLAG_B)) {}
// A is set but not B
if ((flags & FLAG_A|FLAG_B) =3D=3D FLAG_A) {}
/Per W
On Fri, 17 Mar 2006, Noorez Kassam wrote:
> I have a question about flags. Here's an example of my problem:
>
> FLAG A =3D 1;
> FLAG B =3D 2;
>
> Lets say both flags are needed, so they are | together like so... A|B. Ho=
w
> can I then find what flags are set later on from the single value?
>
> _________________________________________________________________
> Take advantage of powerful junk e-mail filters built on patented Microsof=
t=AE
> SmartScreen Technology.
> http://join.msn.com/?pgmarket=3Den-ca&page=3Dbyoa/prem&xAPID=3D1994&DI=3D=
1034&SU=3Dhttp://hotmail.com/enca&HL=3DMarket_MSNIS_Taglines
> Start enjoying all the benefits of MSN=AE Premium right now and get the
> first two months FREE*.
>
>
>
> -------------------------------------------------------
> This SF.Net email is sponsored by xPML, a groundbreaking scripting langua=
ge
> that extends applications into web and mobile media. Attend the live webc=
ast
> and join the prime developer group breaking into this new coding territor=
y!
> http://sel.as-us.falkag.net/sel?cmd=3Dlnk&kid=3D110944&bid=3D241720&dat=
=3D121642
> _______________________________________________
> Dev-cpp-users mailing list
> Dev...@li...
> TO UNSUBSCRIBE: http://www23.brinkster.com/noicys/devcpp/ub.htm
> https://lists.sourceforge.net/lists/listinfo/dev-cpp-users
>
|