Created
March 18, 2012 22:12
-
-
Save haldun/2082879 to your computer and use it in GitHub Desktop.
flags in c with enum
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
typedef enum { | |
kShareViewTypeNone = 0, | |
kShareViewTypeFacebook = 1 << 0, | |
kShareViewTypeTwitter = 1 << 1, | |
kShareViewTypeAll = kShareViewTypeFacebook | kShareViewTypeTwitter | |
} ShareViewType; | |
int main (int argc, char const *argv[]) | |
{ | |
ShareViewType shareViewType = kShareViewTypeFacebook; | |
shareViewType |= kShareViewTypeTwitter; | |
if (shareViewType & kShareViewTypeTwitter) { | |
printf("twitterda paylas\n"); | |
} | |
if (shareViewType & kShareViewTypeFacebook) { | |
printf("fasbukte paylas\n"); | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment