i have problems with strcmp and gets

Viewed 13
case 4:
    {char password[5],passwordr[]="bene";
        
        printf("\nWhats your password? :");
        fgets(password,5,stdin);
        
        if(strcmp(password,passwordr)==0){
            printf("Hello");
        }
        else{
            printf("good buy!");
          }
        }
        break;

I have the problem that this code doesn't work. All other cases from the switch statmante work very well. The problem ist, that I can not write some text with fgets. The compiler automatically jumps to the else statement. At the storage for passwort there ist only "\n".

0 Answers
Related