From the course: C: Data Structures, Pointers, and File Systems

Unlock the full course today

Join today to access over 22,400 courses taught by industry experts or purchase this course individually.

Exploring string functions

Exploring string functions - C Tutorial

From the course: C: Data Structures, Pointers, and File Systems

Start my 1-month free trial

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, lest the compiler complain. The three functions explored in this movie are string length, string compare and string string, which searches for text from one string inside another. The string length, or strlen function, has this format: It's single argument is a string variable or string literal. The value returned is an integer: The number of characters in the string. The length doesn't count the double quotes enclosing the string literal or the null character at the end of the string and escape characters within the string, 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 nine and stored in variable len. The printf statement reports the results. Build and run. And the string is 24 characters long. The string…

Contents