From the course: C Standard Library
Unlock the full course today
Join today to access over 22,400 courses taught by industry experts or purchase this course individually.
String examination
- [Instructor] Following a review of string.h, here we have some string examination functions. The first couple are strlen and strnlen_s which return the length of the string sent us an argument. As usual, the second function receives a second argument for the maximum length before giving up. Next we have string comparison functions. Again we have a naive traditional function strcmp and a safer version strncmp with a maximum length argument. These functions receive two strings as arguments named as if the function was a comparison operator. The first argument is the left-hand side string, and the second one is the right-hand side string. Now one thing I like about these functions is that they don't just check if two strings are equal. Instead, they return a negative value if the left-hand side string is supposed to appear before the right-hand side string in alphabetical order. Meaning that the left-hand side string is less than the right-hand side string. The return value is zero if…
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.