Two C library functions that manipulate strings are strcpy() and strcat(). The strcpy() function copies a string into a buffer. The strcat() function appends, or concatenates, one string to the end of another. Always remember when copying or concatenating strings to ensure that the buffers are capable of storing all characters in the resulting string.
- [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 example …
- Working with arrays
- Building a structure
- Creating an array of structures
- Testing characters
- Working with strings in C
- Using pointers to manipulate data
- Manipulating files
- Using command-line arguments
- Working with time functions
Skill Level Intermediate
1. Arrays and Structures
2. Characters and Strings
4. Files and the Operating System
5. The Interesting and Extraordinary
Next steps1m 52s
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.