Date Archives February 2018

What does the symbol ‘&’ mean in C and C++?

ampersand

‘&’ symbol has two meanings in C and C++.

  • Address of Operator: returns address of a variable.
    • int a = 3;
    • printf(“%d”, a);
      • will return value of a: 3
    • printf(“%d”, &a);
      • will return address of variable a.

 

  • Bit-wise Operator &: operates on bitlevel
    • Example:table_bitwise_operator
    • int a = 13&4;
      • 13 = 1101
      • 4  =0100
      • 13&4 = 0100
      • a = 4