![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
When you delimit a sequence of characters by double-quotation marks, you
are 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 "Food"
.
0 1 2 3 4 <----- Array index | | | | | v v v v v -------- -------- -------- -------- -------- Memory addresses --* ----*--------*--------*--------*--------*--------*--------*--- | |01000110|01101111|01101111|01100100|00000000| | | ---*--------*--------*--------*--------*--------*--------*---- | 920 921 922 923 924 925 926 <-----* -------- -------- -------- -------- -------- ^ ^ ^ ^ ^ | | | | *----- End-of-string code F o o d <----- Encoded character
Note that the four characters in Food are actually stored in a five-element array in which the last element is filled by the null character, usually an all-zero byte, rather than by an actual character's code.
Character arrays terminated by null characters are called character
strings, or, more succinctly, strings. Thus, "Food"
is a
notation for a string. Somewhat colloquially, most programmers say that
"Food"
is a string.