A String in C is nothing but a collection of characters in a linear sequence. Strings are defined as an array of characters. In C programming, a string is a sequence of characters terminated with a null character \0.


Syntax :

data_type    string_name[string_size];  

Declaration of String

1.Char str[6]={‘H’,’E’,’L’,’L’,’O’,’\0’};
2.Char str[]=“hello”;
3.Char str[10];
4.Char *str=“hello”;

String Function & Their Purpose

Strcpy     ⇒ copy one string to another string.
Strcmp   ⇒  compare two strings to each other.
Strlen     ⇒  find the length of the string.
Strrev     ⇒  reverse the string.
Strlwr     ⇒  convert into upper to lower string.
Strupr     ⇒  convert into lower to upper string.
strcat      ⇒  merge two strings.

Watch the Video Lecture



            Previous                                                                                                                       Next