Let's learn how to declare strings and how C handles them.

We'll cover the following

String is one of the most popular data types in programming. To be honest, it’s slightly awkward dealing with character strings in C, especially when compared to languages like Python.

A collection of characters grouped together forms a string. We have seen before how constant character strings are written inside double-quotation marks (line 5 below) as opposed to character constants that are declared using single-quotation marks (line 7 below).

In C, a string is actually, under the hood, an array of characters. String variables can be declared as indicated on line 8 below. The double square brackets signify an array. Just like arrays, we can access string elements through indexing.

Create a free account to access the full course.

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