&
is used two ways, first, you can get the address of a variable:
int *p = &i; // that's fine, p points to i's address
Second it's used to do a "bit-wise" and:
int i = 1; // 01
int j = 3; // 11
int k = i & j; // 01
&&
is a logical operator, not an "address of address of" operator, it's use is in checking two conditions together and asserting that both are true.
if (something && something_else)
EDIT: I just noticed you taged this as C and C++... if this is a C question, see above. If this is a C++ question there's another note on &&
:
C++ Double Address Operator? (&&)
EDIT 2: There's another use of the &&
as a label value operator to take the address of the label.
This is what the error message is about since the compiler is assuming that's what you wanted to do:
The label value operator && returns the address of its operand, which must be a label defined in the current function or a containing function. The value is a constant of type void* and should be used only in a computed goto statement. The language feature is an extension to C and C++, implemented to facilitate porting programs developed with GNU C.
int main()
{
void * ptr1;
label1: ...
ptr1 = &&label1;
...
if (...) {
goto *ptr1;
}
...
}