Program Discussion :: Strings
325 / 60
Write a function to implement strcasecmp().
Answer:
#include
#include
void main()
{
char str1="EXAMPLE";
char str2="example";
int result;
result=strcasecmp(str1,str2);
if(result==0)
printf("strings are equal");
else if(result
Asked In ::
Language:
Geetha
26 Sep, 2018 9:36 PM
#include<stdio.h>
#include<conio.h>
void main()
{
char str1="EXAMPLE";
char str2="example";
int result;
result=strcasecmp(str1,str2);
if(result==0)
printf("strings are equal");
else if(result<0)
printf("%s is less than %s",str1,str2);
else
printf("%s is greater than %s",str1,str2);
}
Language:
Geetha
26 Sep, 2018 9:41 PM
#include<stdio.h>
#include<conio.h>
#include<strings.h>
void main()
{
char *str1="EXAMPLE";
char *str2="example";
int result;
result=strcasecmp(str1,str2);
if(result==0)
printf("strings are equal");
else if(result<0)
printf("%s is less than %s",str1,str2);
else
printf("%s is greater than %s",str1,str2);
}
Language:
Siddhartha Paul
19 Jun, 2019 2:16 PM
#include<stdio.h>
#include<string.h>
int main()
{
char c1[50],c2[50];
printf("Enter string 1: ");
scanf("%s",c1);
printf("Enter string 2: ");
scanf("%s",c2);
//strcasecmp() function compares 2 strings by ignoring the cases.
if(strcasecmp(c1,c2)==0)
printf("%s and %s are compared as equal",c1,c2);
else if(strcasecmp(c1,c2)<0)
printf("%s is less than %s",c1,c2);
else
printf("%s is greater than %s",c1,c2);
return 0;
}