Skip to main content
Logo image

Section 20.3 The String Library

We just saw that we cannot update the value of a string with a simple assignment operation (as in
firstName = "Alex"
) in our code. Only during the declaration phase is it possible to initialize using this method (as in char firstName[20] = "Alex";).
Thankfully, C comes with a whole library of functions to help in our work with strings, the C string library. It provides many useful functions that allow us to work with strings. In order to use functions from this library we need to tell the computer that we’ll be doing so with the following line at the top of our code:
#include <string.h>
The following example shows how we can use the string library to update the value of a string within our code:

admin.....open in new window