Illustrate the use of the strcmp function in C

The strcmp function takes two string arguments. Let us call these arguments s1 and s2, respectively. An integer is returned that is less than, equal to, or greater than zero, depending on whether s1 is lexicographically less than, equal to, or greater than s2.

#include <stdio.h>
 #include <string.h>
 
 int main()
 {
    char s1[80],s2[80];
    int outcome;
    printf("Enter two strings : ");
    scanf("%s%s",s1,s2);
    outcome=strcmp(s1,s2);
    printf("nValue returned by strcmp is %d.n",outcome);
    return 0;
 }

Enjoyed this post? Share it!

 

Leave a comment

Your email address will not be published.