Skip to content

Instantly share code, notes, and snippets.

@thetekst
Created December 27, 2011 14:32
Show Gist options
  • Save thetekst/1523820 to your computer and use it in GitHub Desktop.
Save thetekst/1523820 to your computer and use it in GitHub Desktop.
Shift operators (-r -c -e -d -a)
//Shift operators (-r -c -e -d -a)
#include <stdio.h>
int main(void) {
unsigned char used=0;
unsigned char bRead=1;
unsigned char bCreate=1;
unsigned char bEdit=1;
unsigned char bDelete=1;
unsigned char bAll=1;
bRead <<= 0;
bCreate <<= 1;
bEdit <<= 2;
bDelete <<= 3;
bAll = bRead | bCreate | bEdit | bDelete;
used = bRead | bDelete;
if(used & (bRead & bDelete)) printf("Есть право на доступ");
else{printf("нет прав доступа");}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment