Character and String Data Type

Last Updated : Jan 2026


So far we've learned:

int     → integers
float   → floating-point values
double  → higher-precision floating-point values
_Bool   → boolean values

Now we need to understand character and string data types.So First start with character data type:

Character Data Type

A single character is stored in a character variable inside ' ' (single quotes) and format specifier is %c which take 1 byte of memory. For example:

char ch = 'A';

But char is actually an important concept because it connects:

Characters
   ↓
Numbers
   ↓
ASCII / character sets
   ↓
Memory
   ↓
Strings

This lesson builds the foundation for strings, arrays, input, and many later C concepts.

char` Is an Integer Type Here's something interesting.

C defines char, signed char, and unsigned char as integer types. That means:

char ch = 'A';

isn't storing a magical "letter object." The character is represented using a numeric value according to the execution character set.

On systems using ASCII, for example:

'A' → 65
'B' → 66
'C' → 67

So conceptually:

'A'
 ↓
65

on ASCII-based systems,if

char ch = 'A';

printf("%d\n", ch);
printf("%c\n", ch);

On an ASCII system, this prints:

65
A

Think:

         ch
          ↓
     character value
       /       \
      /         \
    %c           %d
    ↓             ↓
    A             65

String Data Type

A sequence of characters is stored in a string variable inside " " (double quotes) and format specifier is %s which take byte, according to length of string.

String is iterable in nature it means you can access each character of string . For example:

char name[] = "Sadhu";

Conceptually, memory contains:

Value    Index Number
  S    →  0
  a    →  1
  d    →  2
  h    →  3
  u    →  4
  \0   →  5

The '\0' tells C that The string ends here.

This is why C strings are closely connected to:

char
+
arrays
+
'\0'

Example:

#include <stdio.h>

int main() {

    char name[] = "Sadhu";

    printf("%s\n", name);

    printf("%c\n", name[0]);
    printf("%c\n", name[1]);
    printf("%c\n", name[2]);
    printf("%c\n", name[3]);
    printf("%c\n", name[4]);
    printf("%c\n", name[5]);

    return 0;
}

Output:

Sadhu
S
a
d
h
u


Liked This Tutorial

Scan QR Code To Leave A Review Or

Click Here To Leave A Review
Scan QR