8.1 C Style Strings
As you learned earlier, the character type denotes an individual character and we define character literals using single quote delimiters:
- char input = 'A';
Characters are encoded as an integer value based on the American Standard Code for Information Interchange (ASCII). They are stored in a single byte of memory. For example, the character 'A' would be encoded as 65, which is the value that would stored in variable input:
In C, the character literal 'A' is quite different from the string literal "A". The reason is that these literals represent two different types of data. That is, they are stored and processed in different ways. In Python, there is no separate character data type. Instead, you can only create and work with strings. If you need a single character, you would create a string containing that specific character.
The C programming language does not define a built-in data type for creating string variables, but it does provide for the creation and use of strings. Strings are stored and represented as a character array, that is, an array containing char elements. Consider the literal string
"Hello, World"
which would be stored in an array as
A C string is terminated by a special character called the null character, denoted '\0'. The null character, which is encoded by the integer value 0, is used to indicate the end of the character sequence that comprises the string. Without the null character, the character array would be just another array.

A string in C is an array of characters that are terminated by the null character ('\0').
For each of the following character literals, identify that character's ASCII value.
| Character | ASCII Code | Explanation |
|---|---|---|
'B' |
66 | The capital letters of the English alphabet are all encoded in sequence. |
'x' |
120 | |
'a' |
97 | |
'1' |
49 | |
'\n' |
10 | |
'+' |
43 |