strcmp - Devbhoomi

FREE JOB ALERT & ONLINE TUTORIALS

Hot

Post Top Ad

Sunday 5 November 2017

strcmp

The strcmp(first_string, second_string) function compares two strings.
Syntax :
strcmp(first_string, second_string)
Example :

    #include <stdio.h>

    int main(void)
    {
    char firststring[20],secondstring[20];

    printf("Enter first string : ");
    gets(firststring);//reads string from console

    printf("\nEnter second string : ");
    gets(secondstring);

    if(strcmp(firststring,secondstring)==0)
    printf("\nStrings are equal");

    else
    printf("\nStrings are not equal");

    }

No comments:

Post a Comment

Post Top Ad