C语言 判断密码是否正确并返回 可以判断是否正确,但是密码错误后就没办法判断


#include <stdio.h>
#include <math.h>
#include <string.h>
#include <ctype.h>
#include <stdlib.h>
#include<conio.h>
int main(){
    char Password[100],str[100]="admin";
    strcpy(Password,str);
    printf("%s\n",Password);
    char str43[100];
    int CSS=0;
    while(str43[CSS]=getch())
    {
        if(str43[CSS]==13){
            break;
        }
        if(str43[CSS]!='\b'){
            printf("*");
            CSS++;
        }
        else{
                printf("\b \b");
                CSS--;
            }
    }
    str43[CSS]='\0';
    printf("\n");
    printf("%s\n",str43);
    GATE:
    if(strcmp(str43,Password)==0)
    {
        printf("Yes\n");
    }
    else
    {
        printf("Invalid password.\n");
        printf("Enter the password:");
        while(str43[CSS]=getch())
        {
            if(str43[CSS]==13){
                break;
            }
            if(str43[CSS]!='\b'){
                printf("*");
                CSS++;
            }
            else{
                printf("\b \b");
                CSS--;
            }
        }
        str43[CSS]='\0';
        printf("\n");
        goto GATE;
    }
    return 0;
}

img


#include <stdio.h>
#include <math.h>
#include <string.h>
#include <ctype.h>
#include <stdlib.h>
#include<conio.h>
int main() {
    char Password[100] = {0}, str[100] = "admin";
    strcpy(Password, str);
    printf("%s\n", Password);
    char str43[100];
    int CSS = 0;
    while (str43[CSS] = getch())
    {
        if (str43[CSS] == 13) {
            break;
        }
        if (str43[CSS] != '\b') {
            printf("*");
            CSS++;
        }
        else {
            printf("\b \b");
            CSS--;
        }
    }
    str43[CSS] = '\0';
    printf("\n");
    printf("%s\n", str43);
GATE:
    if (strcmp(str43, Password) == 0)
    {
        printf("Yes\n");
    }
    else
    {
        CSS = 0;
        str43[0]='\0';
        printf("Invalid password.\n");
        printf("Enter the password:");
        while (str43[CSS] = getch())
        {
            if (str43[CSS] == 13) {
                break;
            }
            if (str43[CSS] != '\b') {
                printf("*");
                CSS++;
            }
            else {
                printf("\b \b");
                CSS--;
            }
        }
        str43[CSS] = '\0';
        printf("\n");
        goto GATE;
    }
    return 0;
}