In this post we will see how to check if two strings are equal in C.For this we will use strcmp function. It compares two strings lexicographically i.e character by character, if the two character matches moves to next character and compares it. It returns 0 if both strings are equal. #include<stdio.h> #include<string.h> int main() { char str[25]; printf("Enter string 1.\n"); gets(str); char str1[25]; printf("\nEnter string 2.\n"); gets(str1); int i = strcmp(str, str1); if(i==0) { printf("Equal.\n"); } else { printf("Not Equal.\n"); } return 0; }