▪️ This function compares two strings to find out whetherthey are same ordifferent.
▪️ If two strings are found identitcal, this function returns zero "0", otherwise returns a numeric difference between ASCII valueof non matching characters.
▪️ The general form of strcmp() is
I=strcmp(str1,str2);
Example:
#include<stdio.h>
#include<string.h>
void main()
{
int i ;
char s1[15]="Mrug garud",s2[15]="Mrug kolhekar";
i = strcmp(s1, s2);
if(i == 0)
{
printf(" two strings are same");
}
else
{
printf( " two strings are different");
}
}
2] strupr() function:
▪️ Thisfunction converts the caracters of string variable to upper case.
▪️ The general format of strupr() is
Strupr(string);
Example:
#include<stdio.h>
#include<string.h>
void main()
{
char name [15]="akash";
strupr(name);
printf("Enter your good name=%s",name);
}
▪️ Output:
Enter you good name= AKASH
3] strlwr() function:
▪️ This function convers the character of string variable to lower case.
▪️ The general form of strlwr() function is
strlwr (string);
Example:
#include<stdio.h>
#include<string.h>
void main()
{
char str[10]="AKASH";
strlwr(str);
printf("New string=%s",str);
}
Output:
New caracter string = akash
4] strrev() function:
▪️ This function reverses the characters of string variable.
▪️ The general form of strrev() function is
strrev(string);
Example:
#include<stdio.h>
#include<string.h>
void main()
{
char str[10]="MRUGNAYANI";
strrev(str);
prntf("New strig=%s",str);
}
Output:
New string=INAYANGURM
5] strstr() function:
▪️ This is a two parameter function that can be used to locate a sub string in a string.
▪️ The general form of strstr() function is
i = strstr(string,substring)
Example:
#include<stdio.h>
#include<string.h>
void main()
{
char str[30]="how are you friends";
int i;
i=strstr(str, "are");
if(i==null)
{
printf("string is not found");
}
else
{
printf(" strig is found ");
}
}
Output:
string is found
6] strset() function:
▪️ The function is used to set all characters of a string to the given character.
▪️ The general form of strset() function is
strset(string, character);
Example:
#include<stdio.h>
#include<string.h>
void main()
{
char str[10]=" sky ";
strset(str, 'x');
printf(" New string = %s ",str);
}
Output:
New string = x x x
This theme bis not adjustable with smartphone so please set responsive theme for your blog
ReplyDeleteMy link
https://vcarskill2020.blogspot.com/2020/09/kia-sonet-review.html?m=1
https://vcarskill2020.blogspot.com/2020/09/kia-sonet-review.html?m=1
Done bro,change the theme as you say...🙂
DeleteReally helpful 👍
ReplyDelete