1 00:00:06,972 --> 00:00:08,870 CHRISTOPHER BARTHOLOMEW: Welcome back. 2 00:00:08,870 --> 00:00:12,730 In another video, we discussed the char data type in C which 3 00:00:12,730 --> 00:00:16,570 can be used to hold letters, numbers and special characters 4 00:00:16,570 --> 00:00:19,420 such as the question or exclamation mark. 5 00:00:19,420 --> 00:00:22,660 We know that an individual char has an ASCII value, which 6 00:00:22,660 --> 00:00:25,280 is an integer representation of the character. 7 00:00:25,280 --> 00:00:29,690 For example, capital letter A's ASCII value is 65. 8 00:00:29,690 --> 00:00:34,570 But in C, what do we use for actual words or sentences such 9 00:00:34,570 --> 00:00:37,940 as programming, or "C is beautiful?" 10 00:00:37,940 --> 00:00:39,550 The answer is a string-- 11 00:00:39,550 --> 00:00:42,340 but to be more specific, it is a character string. 12 00:00:44,850 --> 00:00:48,250 A character string, or a string, is a sequence of one 13 00:00:48,250 --> 00:00:50,210 byte chars that are stored alongside 14 00:00:50,210 --> 00:00:52,000 each other in memory. 15 00:00:52,000 --> 00:00:55,000 And at the end of any character string in the C 16 00:00:55,000 --> 00:00:57,190 language, there's one additional byte that is 17 00:00:57,190 --> 00:00:59,410 allocated for a special character-- 18 00:00:59,410 --> 00:01:03,565 backslash 0, which is the null termination character. 19 00:01:03,565 --> 00:01:07,290 The null termination character is a 1 byte char whose bits 20 00:01:07,290 --> 00:01:10,900 are all 0 and it is used to signal the end 21 00:01:10,900 --> 00:01:12,860 of a string in memory. 22 00:01:12,860 --> 00:01:16,370 This means whether you intend to initialize your string as 23 00:01:16,370 --> 00:01:22,610 the sentence "C is fun," or just the word "fun," at the 24 00:01:22,610 --> 00:01:26,100 end there will always be a null termination character 25 00:01:26,100 --> 00:01:29,420 indicating that the string has ended. 26 00:01:29,420 --> 00:01:32,200 To use a string in your program, it is recommended 27 00:01:32,200 --> 00:01:34,440 that you initialize your variable as this-- 28 00:01:38,050 --> 00:01:46,720 chart star S equals open quote, your string, close 29 00:01:46,720 --> 00:01:50,220 quote, semicolon. 30 00:01:50,220 --> 00:01:54,880 In this variable definition, variable S points to the first 31 00:01:54,880 --> 00:02:01,040 character in our string, which is C. You see, because we now 32 00:02:01,040 --> 00:02:04,500 know the entire string is stored sequentially in memory, 33 00:02:04,500 --> 00:02:08,009 we can retrieve the string with no problems as we also 34 00:02:08,009 --> 00:02:09,919 know where it ends, too-- 35 00:02:09,919 --> 00:02:12,060 the null termination character. 36 00:02:12,060 --> 00:02:13,350 So have fun. 37 00:02:13,350 --> 00:02:16,750 I'm Christopher Bartholomew, this is cs50.