#include<stdio.h>
#include<string.h>intmain(){chara[20],b[20];printf("———————————————————————————————————————————");printf("\nProgram to compare two strings");printf("\n———————————————————————————————————————————");printf("\nEnter the 1st string ");scanf("%s",a);printf("\nEnter the 2nd string ");scanf("%s",b);intc=strcmp(a,b);if(c==0){printf("\nStrings are equal");}else{printf("\nStrings are unequal");}printf("\n———————————————————————————————————————————\n");return0;}
Output
kodingwindow@kw:~$ gcc kw.c kodingwindow@kw:~$ ./a.out
———————————————————————————————————————————
Program to compare two strings
———————————————————————————————————————————
Enter the 1st string HELLO
Enter the 2nd string WORLD
Strings are unequal
———————————————————————————————————————————
kodingwindow@kw:~$ ./a.out
———————————————————————————————————————————
Program to compare two strings
———————————————————————————————————————————
Enter the 1st string WORLD
Enter the 2nd string WORLD
Strings are equal
———————————————————————————————————————————
kodingwindow@kw:~$
Dear User, Thank you for visitng KodingWindow. If you are interested in technical articles, latest technologies, and our journey further, please follow us on LinkedIn.