Character Arrays and Strings
Learn how to store alphabets and words using character arrays and strings in C++.
We'll cover the following
In C++, when we want to work with text, we can use either a string object or a character array. For now, think of these as different ways to store and handle the text. In this lesson, we’ll explore both concepts and learn how they work.
What is a character array?
A character array is a sequence of individual characters stored in consecutive memory locations. Think of it like a train with multiple compartments, where each compartment can hold one character. We can declare a character array using the char
keyword followed by parenthesis []
with the number of characters.
For example, a character array named Educative
containing 8
characters can be declared as follows:
Create a free account to access the full course.
Continue your learning journey with a 14-day free trial.
By signing up, you agree to Educative's Terms of Service and Privacy Policy