CHRISTOPHER BARTHOLOMEW: Welcome back.
In another video, we discussed the char data type in C which
can be used to hold letters, numbers and special characters
such as the question or exclamation mark.
We know that an individual char has an ASCII value, which
is an integer representation of the character.
For example, capital letter A's ASCII value is 65.
But in C, what do we use for actual words or sentences such
as programming, or "C is beautiful?"
The answer is a string--
but to be more specific, it is a character string.
A character string, or a string, is a sequence of one
byte chars that are stored alongside
each other in memory.
And at the end of any character string in the C
language, there's one additional byte that is
allocated for a special character--
backslash 0, which is the null termination character.
The null termination character is a 1 byte char whose bits
are all 0 and it is used to signal the end
of a string in memory.
This means whether you intend to initialize your string as
the sentence "C is fun," or just the word "fun," at the
end there will always be a null termination character
indicating that the string has ended.
To use a string in your program, it is recommended
that you initialize your variable as this--
chart star S equals open quote, your string, close
quote, semicolon.
In this variable definition, variable S points to the first
character in our string, which is C. You see, because we now
know the entire string is stored sequentially in memory,
we can retrieve the string with no problems as we also
know where it ends, too--
the null termination character.
So have fun.
I'm Christopher Bartholomew, this is cs50.