I think you are confused by the syntax of pointer
initialization in C, which **is** confusing in that it
overloads the dereference operator "*". Specifically, in
the initialization statement
int * ipa = &a; // initialization of the pointer;
// "&a" is the address of an integer
the "*" means you are declaring "ipa" to be a pointer to
int, and you initializing it by making it point to "a".
Now once you have declared the pointer, however, the
meaning of "*" is different in an assignment statement:
*ipa = b; // assignment to "* ipa" (i.e., to "a");
// b is the value of an integer
Here "*" means to dereference the pointer (i.e., go
to "a") and store the integer "b" there. So the right-
hand-side of the initialization requires an address, but
the right-hand-side of the assignment statement requires a
value, even though the "*" operator appears on the left-
hand side of both statements. To make this a little
clearer, consider that once you have declared "ipa" to be
a pointer, then you can make it point to a different
integer by storing a new address in "ipa":
ipa = &c; // assignment to "ipa" (not to "* ipa");
// "ipa" now points to "c", not to "a"
Here there is no "*" operator, even though there was one
in the intialization statement, which made "ipa" point
to "a" originally. So the "problem" is just one of C
syntax, in which "*" means different things in different
places. Did I understand you correctly?
Wil
-----Original Message-----
Hi,
I saw a sentence :
int a = 47;
int* ipa = &a;
Then ipa contains the address of a.
But I think, if &a=0065FE00, then the second sentence
is: int* ipa = 0065FE00;
so *ipa should contains the address of a?
What's wrong? I feel puzzled.
Thanks.
Tommy Shore
.