When you delimit a sequence of characters by double quotation marks, you
are really telling C++ to create an array in which
the elements are the particular characters between the double
quotation marks. The following, for example, is what C++ stores on
encountering "box"
.
0 1 2 3 <----- Array index | | | | 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 characters
Note that the three characters in box
are actually stored in a
four-element array in which the last element is filled by the
null character, rather than by an actual character's code.
Character arrays terminated by null characters are called character
strings, or, more succinctly, strings. Thus, "box"
is a
notation for a string. Somewhat colloquially, most programmers say that
"box"
is a string.