Pages

Write a program to Compare two strings by using strcmp function in c language

Sunday 6 July 2014

#include <stdio.h>
#include <string.h>
#include <conio.h>

int main()
{
   char str1[100], str2[100];

   printf("Enter the first string: ");
   gets(str1);

   printf("Enter the second string: ");
   gets(str2);

   if( strcmp(str1, str2) == 0 )
   {
      printf("Entered strings are equal.\n");
   }
   else
   {
      printf("Entered strings are not equal.\n");
   }
 
getch();
}

 

Search Box

Most Reading

Contact Form

Name

Email *

Message *