From the course: C: Data Structures, Pointers, and File Systems
Unlock the full course today
Join today to access over 22,600 courses taught by industry experts or purchase this course individually.
Understanding strings in C - C Tutorial
From the course: C: Data Structures, Pointers, and File Systems
Understanding strings in C
- [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, though…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
Using single character I/O4m 4s
-
(Locked)
Testing characters2m 34s
-
(Locked)
Working with character conversions2m 17s
-
(Locked)
Understanding strings in C3m 3s
-
(Locked)
Fetching string input3m 18s
-
Sending string output2m 46s
-
(Locked)
Reviewing printf() placeholders3m 8s
-
(Locked)
Using printf() placeholders3m 36s
-
(Locked)
Exploring string functions3m 29s
-
(Locked)
Manipulating strings3m 53s
-
(Locked)
Avoiding string problems2m 27s
-
(Locked)
Challenge: String I/O and manipulation1m 46s
-
(Locked)
Solution: String I/O and manipulation2m 16s
-
-
-
-
-