String Handling Using the C Standard Library

Learn how the C standard library enables us to manage strings using functions for concatenating strings, finding their lengths, testing for equality, as well as allowing conversions between strings and numbers.

The C standard library, (which we can load into our program by including the directive #include <string.h> at the top of your program), contains many useful routines for manipulating these null-terminated strings.

It’s a good idea to consult a reference source for a long list of all the functions that exist for manipulating null-terminated strings in C. There are functions for copying strings, concatenating strings, getting the length of strings, comparing strings, etc.

Concatenating and finding length

If we place two string constants together side by side, the C compiler will concatenate the constants. This doesn’t apply to strings that are stored as arrays of characters and for them we explicitly need to use the strcat function.

Create a free account to access the full course.

By signing up, you agree to Educative's Terms of Service and Privacy Policy