String Handling Functions in C
In C language, an array of characters is known as a string. It has the following syntax :
char sk[15]; // It declares a string array with 15 characters.
There are four types of String Handling Functions in the C language.
1. strlen()
2. strcpy()
3. strcat()
4. strcmp()
strlen(): This function is used to find the length of a character string.
Syntax:
int n; char sk[15]="Las Vegas"; n=strlen(sk);
strcpy(): This function is used to copy a character string to a character variable.
Syntax:
char sk[15]; strcpy(sk, "Las Vegas");
strcat(): This function is used to join character strings.
Syntax:
char sk[15]="Las Vegas"; char pin[10]="88905"; strcat(sk,pin);
strcmp(): This function is used to compare two character strings.
Syntax:
char sk[15]="Las Vegas"; char rp[15]=" New York"; strcmp(sk,rp);