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 - C Tutorial
From the course: C: Data Structures, Pointers, and File Systems
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…
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
-
Testing characters2m 34s
-
Working with character conversions2m 17s
-
Understanding strings in C3m 3s
-
Fetching string input3m 18s
-
Sending string output2m 46s
-
Reviewing printf() placeholders3m 8s
-
Using printf() placeholders3m 36s
-
Exploring string functions3m 29s
-
Manipulating strings3m 53s
-
Avoiding string problems2m 27s
-
Challenge: String I/O and manipulation1m 46s
-
Solution: String I/O and manipulation2m 16s
-
-
-
-
-