![]() |
![]() |
![]() |
![]() |
![]() |
|
The following declaration creates a character-pointer
variable and arranges for the initial value of that variable to
point to the first character in the "box" string:
char *character_pointer = "box";
Thus, a character-pointer declaration, with a string provided as the initial value, produces an arrangement of memory such as the following:
character_pointer
*--------*--------*
|00000011|10011000| <----- Value of character_pointer variable
*--------*--------* is a pointer to the first element
----------------- of the "box" string
|
*-------*
|
| 0 1 2 3 <----- Array index
| | | | |
v v v v v
-------- -------- -------- -------- Memory addresses --*
----*--------*--------*--------*--------*--------*--------*--- |
|01100010|01101111|01111000|00000000| | | |
---*--------*--------*--------*--------*--------*--------*---- |
920 921 922 923 924 925 926 <-*
-------- -------- -------- --------
^ ^ ^ ^
| | | *----- End-of-string code
b o x <----- Encoded character