String comparison in C

A String function,strcmp() are used here to compute with strings.

Source code :

#include <stdio.h>
#include <string.h>
int main()
{
     char str1[20] = "aroliant";
     char str2[20] = "codecry";
     if (strcmp(str1, str2) ==0)
     {
        printf("string 1 and string 2 are equal");
     }else
      {
         printf("string 1 and 2 are different");
      }
     return 0;
}

Output :

string 1 and 2 are different

Notes :

strcmp() compares both the string and return true(1) if both are same and false(0) if both are different.Here we have printed the statements directly.


Output :


                

Comments :