The C language lacks a string data type, so a character array is used instead. The character array must end with the null character, literal \0 and value zero, for it to be considered a string. Literal strings are automatically appended with the null character by the compiler. For string buffers, you must remember to allocate storage for the null character at the end of the string.
- [Instructor] A string isn't a data type in the C language. … Instead, a character array represents a string. … The final character in the array must be the null character. … It marks the end of the string and it's not displayed. … The null character is ASCII code zero. … It's represented as the character literal backslash zero. … This character isn't counted in the strings length, … but storage must be allocated for the null character … which can trip you up if you're not careful. … Also, keep in mind that the null character isn't the same … as the NULL, all caps, pointer constant. … The null character has nothing to do with pointers. … To declare a string in C, you create a character array. … This array is named string. … The square brackets are empty … and the string literal is a sign. … The compiler allocates the proper amount … of storage for the string and the null character … is automatically appended to the string literal. … Another way to allocate the same string … is to specify individual character values, …
- Working with arrays
- Building a structure
- Creating an array of structures
- Testing characters
- Working with strings in C
- Using pointers to manipulate data
- Manipulating files
- Using command-line arguments
- Working with time functions
Skill Level Intermediate
1. Arrays and Structures
2. Characters and Strings
4. Files and the Operating System
5. The Interesting and Extraordinary
Next steps1m 52s
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.