Strings in C Language

Strings in C are a group of characters, digits, and symbols enclosed in quotation marks or simply we can say the string is declared as a “character array”.

The end of the string is marked with a special character, the ‘\0’ (Null character), which has the decimal value 0.

There is a difference between a character stored in memory and a single character string stored in a memory.

The character requires only one byte whereas the single character string requires two bytes (one byte for the character and another byte for the delimiter).

A string can be represented as a single-dimensional character type array. C language does not provide the intrinsic string types. Some problems require that the characters within a string be processed individually.

However, there are many problems which require that strings be processed as complete entities. Such problems can be manipulated considerably through the use of special string oriented library functions.

Most of the C compilers include string library functions that allow string comparison, string copy, concatenation of strings etc.

The string functions operate on null-terminated arrays of characters and require the header <string.h>.

In this tutorial, we are discussing

  • How to define, declare and initialize a string;
  • various formatting techniques to display the strings; and
  • various built-in string functions and their use in manipulation of strings.


2 thoughts on “Strings in C Language

Leave a Reply

Your email address will not be published. Required fields are marked *

%d bloggers like this: