From the course: Secure Coding in C (2019)
Unlock the full course today
Join today to access over 24,800 courses taught by industry experts.
Minding string functions - C Tutorial
From the course: Secure Coding in C (2019)
Minding string functions
- [Instructor] The thing that makes a string in C, as well as many programming languages, is the null character. It terminates the string, marking the final character, which is an output. The null character is ASCII code zero, represented in C as the escape character, \0. String literals in C are created with an automatically appended null character. Strings you spin up yourself must be terminated with the null character. You code the null character, the compiler won't check it for you. And if you omit the null character, the string's end is undetermined, which leads to an overflow, an unsafe condition. Many of the C libraries string functions rely upon and maintain the null character when manipulating strings. Still, other functions may not set the null character, nor do the functions watch for overflows. In this code, the strncpy function copies characters, four of them, from string source to string dest. String…
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
-
-
-
-
-
-
(Locked)
Allocating strings2m 40s
-
(Locked)
Avoiding bad string assignment1m 28s
-
(Locked)
Working with string literals2m
-
(Locked)
Minding string functions3m 47s
-
(Locked)
Storing passwords and codes1m 15s
-
(Locked)
Clearing data after use1m 13s
-
(Locked)
Challenge: The secret code40s
-
(Locked)
Solution: The secret code1m 43s
-
(Locked)
-
-