What does & stands for in C and mmap()

梦想的初衷 提交于 2019-12-14 03:32:52

问题


int fd = open("/dev/mem", O_RDWR);
present = (unsigned char *)mmap(0, 
              getpagesize(), 
              PROT_READ|PROT_WRITE, 
              MAP_SHARED, 
              fd, 
              0x22400000);

if ((*present & 1) == 0)
{
  printf("Converter not present\n");
  exit(1);
}

1) What does '&' operator mean in the preceding code?


回答1:


It is the bitwise and operator. This means that the result of the operation is to perform binary and of the two operands but bit-by-bit (in a bitwise fashion i.e).

In this case it is checking that the first bit of the memory pointed to by present is 0.



来源:https://stackoverflow.com/questions/14928972/what-does-stands-for-in-c-and-mmap

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!