Hacker News new | ask | show | jobs
by deathanatos 4011 days ago
Sibling posts have correctly pointed out that the & here is a bitwise AND. However, I wanted to note that `&` is also the take-address-of operator in C, which is why you think it has to do with pointers: there are two operators (one taking the address of something, the result of which is a pointer, another taking a bitwise AND); they both use the same symbol "&".

The difference is that the AND is a binary operator — i.e., it takes two arguments:

    A & B
whereas the address-of operator "&" is a "unary" operator; it only takes one argument:

    &A
There can be something before it in a more complete context, such as:

    x = 3 + &y;
(though this is more often conventionally written the other way "&y + 3"; I only use this for demonstration)

But here "+" is the binary operator. (You can't have two binary operators in a row; that would be like "3 + * 2", which is nonsensical.) This is similar to "3 + -2": the negative here is a unary operator, the "+" here is the binary operator "add"