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.
Manipulating strings - C Tutorial
From the course: C: Data Structures, Pointers, and File Systems
Manipulating strings
- [Instructor] The C language is rather thin on string manipulation functions. This limitation poses no problem as you can easily craft your own. Two functions available to you in the standard C library are string copy to copy strings and string cat to concatenate strings or append one string to the end of another. Both functions are prototyped in the string.h header file. The string copy function has this format. The first argument is the destination buffer to which the second argument, the source string, is to be copied. It's vital that the destination buffer be large enough to accommodate the string copied into it. In this exercise file, a string original is declared at line six. Line seven declares duplicate, an empty buffer with more than enough storage to hold the original string. The string copy function at line 10 copies the original string into the duplicate buffer and line 11 displays the result. Build in one and there you go. This exercise file improves upon the proceeding…
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
-
-
-
-
-