We can define the C Programming String as it is a Character’s arrays. Basically string in c program means that a complete string is a combination of characters. And this character is stored in an array to form a complete string. It is only because C programming language has no String type of data type.

This character of an array is a one-dimensional array that is terminated by a null(‘\0’). This null help to identify the end of the character array.

Each Character occupies one byte of Memory.

We can say that Strings are the form of data used in programming for storing and manipulating text, such as words, names, and sentences.

Declaration of strings: We can declare a string easily as we declare an array. Below is the fundamental syntax structure for declaring a string.

char str_name[size];

In the above syntax structure, str_name is any name given to the string variable as well as size is used to define the size of the string, i.e the number of characters strings will certainly keep. Please keep in mind that there is an additional ending character which is the Null character (‘\ 0’) used to show termination of string which varies in strings from normal character arraysString Example:-

Here is a bunch of operation we can perform on string

String Example using C Program

1
2
3
4
5
6
7
8
9
10
#include<stdio.h>
#include<conio.h>
void main()
{
char n1[]={'T','u','t','o','r','i','a','l','w','o','r','l','d','\0'};
char n2[]="Tutorialworld";
printf("\n%s",n1);
printf("\n%s",n2);
getch();
}

Output:-

Let’s see another example of string in C programming language for better understanding. In this example we will see how ‘/0’ is working?

C Program to calculate the length of string

1
2
3
4
5
6
7
8
9
#include <stdio.h>
#include<conio.h>
int main() {
    char s[] = "tutorial world is educational website";
    int i;
    for (i = 0; s[i] != '\0'; ++i);
    printf("Length of string is %d", i);
    getch();
}

Output :

With the help of above program you can realize the space is also calculated as a string in C. So we cannot ignore the space while counting the size of char array which form a string.