From the course: Complete Guide to C Programming Foundations

Unlock the full course today

Join today to access over 24,800 courses taught by industry experts.

Exploring string functions

Exploring string functions

- [Instructor] The C library offers a host of functions for examining and manipulating strings. These are defined in the string.h header file, which must be included in your source code when you use the functions, lest the compiler get cross with you. Two examples of string manipulation functions are: string length and string compare. The string length function has this format. Its single argument is a string variable or string literal. The function returns an integer, the number of characters in the string. This is a size_t data type, an integer that represents bites of storage in memory. The length value return doesn't include the double quotes enclosing a string literal or the null character terminating the string. Escaped characters, such as \n for new line, are counted as single characters. In this exercise file, the length of the string, string, is obtained at line 9 and stored in integer variable len. The string.h header file is included for the definition of the strlen…

Contents