Why doesn’t the C Programming Language support a string variable data type?

String is not a basic data type in C programming language. C may lack a string variable type but it does, however, have character variables. A string variable in C is really a character array made out of character variables.

A string is a group of characters(char type of data) terminated by the NULL character. (‘\0’). Whenever a program in C does an operation using a string like comparing it, printing it or copying it to another string, it does it until it encounters a NULL which is nothing but the ASCII code zero (‘\0’).

An array is a collection of data that holds fixed number of values of same type. It can be an array of integers, or it can be of complex data types like structures or pointers. The string is a simple array of char data type.

One way to visualize an array is like this:


Each of the bracket pairs is a slot in the array, and you can store information in slot–the information stored in the array is called an element of the array. It is very much as though you have a group of variables lined up side by side that can be accessed by a numerical index.

In summary, here are the difference between a single character constant and a string constant:

Character Constant
  • A character constant is enclosed within single inverted commas.
  • The maximum length of a character constant can be one character.
  • A single character string constant has an equivalent integer value.
  • The character constant ‘A’ consists of only character A.
  • A single character constant occupies one byte.
  • Every character constant does not end up with a NULL character.
String Constant
  • A sequence of characters enclosed in double quotes
  • A string constant can be any length.
  • A single character string constant does not have an equivalent integer value.
  • The string constant “A” consists of character A and \0.
  • A single string constant occupies two bytes
  • Every string constant ends up with a NULL character which is automatically assigned (before the closing double quotation mark) by the compiler

1 – http://www.peoi.org/Courses/Coursesen/cprog/frame9.html
2 – http://aboutc.weebly.com/string-constants.html
3- http://www.cprogramming.com/tutorial/c/lesson8.html