October 27, 2024
Chicago 12, Melborne City, USA
C#

What is the difference between a , &a and *a?


I am trying to understand the difference between a and &a when a is a pointer.

in the following example code :

int main()
{
    int b = 100;
    int *a;
    a = &b;
    printf("%d %d %d", a , &a , *a);
    return 0;
}

According to my understanding, a is a name given to the address of a. That is :

enter image description here

Therefore I am expecting a and &a to be same when a is a pointer. But in the output, I am getting the first two values ( a and &a ) as different.

Where am I going wrong ?



You need to sign in to view this answers

Leave feedback about this

  • Quality
  • Price
  • Service

PROS

+
Add Field

CONS

+
Add Field
Choose Image
Choose Video