Until the line c = "C";
the pointer c
has no given values, so lines before are undefined behaviors! You try to write value at the address given by c
.
The address displayed before is the random value in c
.
After, your code displays c
value which is the address of the array "C"
then displays the address of the array "D"
. The strings "C"
and "D"
are string literals their have each a fixed address displayed by your code and their address is obviously different.
A pointer is simply a variable which store an address, like an int
can store a integral number. We can read or write where the c
pointer points using a *
. Nether try to do *c
before having set c
.