From the beginning:
b := &a
Here, b
is of type *int
, a pointer to a location in memory where value of a
is stored. When you do *b
, you are accessing a value from the location b
pointer points to.
When you do *b++
, it stands for *b = *b + 1
and you are incrementing a value on the location b
pointer points to.
b = *b + 1
is invalid because you are trying to add *b
and 1
, which are both type of int
, to b
, which is a pointer (type of *int
).