i'm still learning myself but try this
http://www.cplusplus.com/doc/tutorial/po...
In C++, what is the meaning of char * ? How to recall this pointer ? Any simple example..?
In computer memory, each byte has an address and a value.
Given the line
char myVar = 'D';
The compiler puts the value 'D' in some memory address.
In C/C++ you can actually get that address with the %26amp; operator.
char * myValAddress = %26amp;myVal.
Think of the %26amp; operator as the "the address at" operator.
when you see
char * myValAddress = %26amp;myVal
read it in your head as
myValAddress equals "the address at" which myVal is stored.
Now myValAddress is a "pointer" to the location where myVal is stored.
You can now either change or get the value with the variable name myVal, or change the value by "dereferencing" the address pointer with the * operator.
char newVal = myVal;
char newVal = *myValAddress;
think of the * operator as "the value pointed to by"
when you see
*myValAddress = 'F';
read it in your head as
"the value pointed to by" myValAddress equals 'F';
Any quest, email me at redflats@yahoo.com
Reply:A string.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment