int* pc, c;
Here, a pointer pc and a normal variable c, both of typeint
, is created.
Since pc and c are not initialized at initially, pointer pc points to either no address or a random address. And, variable c has an address but contains random garbage value.
c = 22;
This assigns 22 to the variable c. That is, 22 is stored in the memory location of variable c.
pc = &c;
This assigns the address of variable c to the pointer pc.
c = 11;
This assigns 11 to variable c.
*pc = 2;
This change the value at the memory location pointed by the pointer pc to 2.
Categories