0
898views
Write a program to compare two string and find whether they are equal or not.
1 Answer
0
2views
#include<string.h>
main() 
{ 
char s1[20],s2[20],s3[20]; 
int x, l1, l2, l3; 
printf(“Enter two string constants \n”); 
printf(“?”); 
scanf(“%s %s”, s1, s2); 
x = strcmp(s1, s2); 
if(x != 0) 
printf(“Strings are not equal \n”); 
strcat(s1, s2); 
else 
 printf(“Strings are equal \n”); 
strcpy(s3,s1); 
l1 = strlen(s1); 
l2 = strlen(s2); 
l3 = strlen(s3); 
printf(“\ns1 = %s \t length = %d characters \n”,s1, l1); 
printf(“\ns2= %s \t length = %d characters \n”,s2, l2); 
printf(“\ns3 = %s \t length = %d characters \n”,s3, l3); 
}
Please log in to add an answer.