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

Manipulating strings - C Tutorial

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

Start my 1-month free trial

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…

Contents