samedi 25 janvier 2020

Why 'OR operators' in strcmp() doesn't work?

    char text[10];
    fgets(cmd, 10, stdin);

    if (strncmp(cmd, "some text one",13 || "some text two",8) == 0)
    {
        puts("some text");
    }

    if (strncmp(cmd, "some text three",13 || "some text four",13) == 0)
    {
        puts("some text again");
    }

I want to use OR operator here, but when I run it and enter "some text one" - the output is this:

some text
some text again

WHY?

Aucun commentaire:

Enregistrer un commentaire