Problem:- C Program to Compare Two Strings Using strcmp or C program to compare two strings or C Program to Compare Two Strings using strcmp() or C Program to Accepts two Strings & Compare them or C Program to Compare Two Strings Using Library Function or C Program to Compare Two Strings Using strcmp() Function or strcmp function (String Compare) or Compare two string using strcmp function.
Explanation:- Comparing a two string using an inbuilt library function is very simple first we have to take an input (both string, you want to compare ) from user and use a compare inbuilt function if both strings are equal then strcmp return zero and if the both string is not compared then return value by inbuilt function is not equal to zero. The strcmp() function syntax is given below we have to just take an input and put the string in strcmp() library function.
Syntax of strcmp()
strcmp(string1, string2);
where string1 and string2 both are two different-different string we have to compare.
Also Check:- Geeksforgeeks solution for School, Basic, Easy, Medium, Hard in C++.
Extreme Recommended:- Like our Facebook Page or Join our Facebook Group and Google plus Community for up-to-date for a new post or if you have any Query you can ask there with lots of coders also suggest to your Friends to join and like our page.
Solution:-
#include<stdio.h>
#include<string.h>
void main()
{
/*Visit - www.programmingwithbasics.com*/
printf("=====================================");
printf("\nVisit - www.programmingwithbasics.com");
printf("\n=====================================");
while(1)
{
char a[100], b[100];
printf("\n\nEnter The First String: ");
gets(a);
printf("\n\nEnter The Second String: ");
gets(b);
if (strcmp(a,b) == 0)
printf("\n\nStrings Are Equal\n");
else
printf("\n\nStrings Are Not Equal");
}
return 0;
}
Output:-
You May Also See
2. Java Program For Find The Gross Salary Of An Employee
3. C Program For Find A Generic Root Of Number Using While Loop
4. C Program To Print A Calender Taking Input From User Using Loop
5. C Program To Generate IP (Internet Protocol) Addresses Using For Loop
4. C Program To Print A Calender Taking Input From User Using Loop
5. C Program To Generate IP (Internet Protocol) Addresses Using For Loop
6. C++ Program To Find Quotient And Reminder Of Two Numbers Using If/Else Statements
7. C++ Program To Convert A Lowercase Alphabet To Uppercase Alphabet Or Vice-Versa Using If/Else Statements
8. C++ Program To Find Max Number Among Given Three Number Using If/Else Statements
9. C++ Program To Check Year Is Leap Year Or Not Using If/Else Statements
10. C++ Program To Find The HCF Or LCM Of Two Number Using If/Else Statements
7. C++ Program To Convert A Lowercase Alphabet To Uppercase Alphabet Or Vice-Versa Using If/Else Statements
8. C++ Program To Find Max Number Among Given Three Number Using If/Else Statements
9. C++ Program To Check Year Is Leap Year Or Not Using If/Else Statements
10. C++ Program To Find The HCF Or LCM Of Two Number Using If/Else Statements
0 Comments: