String Inbuilt Functions 3

strncmpi() :(compare first “n” characters of  2 strings ignoring case)

This functions helps us to perform a comparison of two string without case sensitivity and of specified number of characters.

syntax:
int a;
a=strncmpi(s1,s2,n);

compares first “n” characters of two strings without case sensitivity

 

#include<stdio.h>
#include<string.h>
int main()
{
    char n1[20],n2[20];
    int a;
    printf("Enter 1st string ");
    gets(n1);
    printf("Enter 2nd string ");
    gets(n2);
    a=strncmpi(n1,n2,2);
    if(a==0)
    printf("Both the strings are same/equal\n");
    else
    printf("Both the strings are not same/equal\n");
    return(0);
}
/* Output */

Enter 1st string hello
Enter 2nd string HELLO
Both the strings are same/equal

Enter 1st string hello
Enter 2nd string abc
Both the strings are not same/equal

strlwr() : (convert string to lower case)

This function helps us to convert a string to lower case. That is all upper case alphabets are converted to lower case rest of then remain as it is.

Syntax:
strlwr(string);

Example:1
n1=”HELLO”;
strlwr(n1);
Output:
hello

Example:2
n1=”ComPu12TER”
strlwr(n1);
Output:compu12ter

code

strupr() : (convert string to lower case)

This function helps us to convert a string to upper case. That is all lower case alphabets are converted to upper case rest of then remain as it is.
Syntax:
Strupr(string);
Example:1
n1=”hello”;
strupr(n1);
Output:
HELLO
n1=”ComPu12Ter”
strupr(n1);
Output:
COMPU12TER

code

strrev() : (String reverse)

This function helps us to reverse the string.
Syntax:
strrev(string);
Example:1
n1=”hello”
strrev(n1);
Output:
olleh
n1=”computer”
strrev(n1);
Output:
retupmoc