C - Using strcmp() function directly in if comparison

Description

Using strcmp() function directly in if comparison

Demo

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

int main()/* w  w  w  . ja v a  2  s  . c  om*/
{
    char password[]="taco";
    char input[15];

    printf("Password: ");
    scanf("%s",input);

    if(strcmp(input,password)==0)
        puts("Password accepted");
    else
        puts("Invalid password. Alert the authorities.");

    return(0);
}

Result

Related Topic