mercredi 26 mai 2021

Is there a function that enables the comparison of two string in an if statement? [duplicate]

I am attempting to include the two scanf strings into the if statement, but it is not allowing me to do so. I believe there may be a function needed.

#include <stdio.h>

int main(void) {
    
    char player1[25];
    char player2[25];
    
    while(1){
        
        scanf("%s%s",player1,player2);
        
        if(player1 == "rock" && player2 == "scissors")
        {
            printf("player 1 wins, rock crushes scissors");
        }
        
        
        printf("Hello, World!\n");
        return 0;
    }
}

Aucun commentaire:

Enregistrer un commentaire