Correction lecture.c
This commit is contained in:
parent
21bc32cdd7
commit
307a131abe
@ -6,16 +6,25 @@ int main(int argc, char * argv[]) {
|
||||
char real_password[] = "test 1212 34";
|
||||
char password[27];
|
||||
|
||||
for (int i = 1; i < argc; i++) {
|
||||
if (i != 1) strcat(password, " ");
|
||||
if (strlen(password) + strlen(argv[i]) > 26) {
|
||||
puts("Mot de passe trop long !");
|
||||
printf("Veuillez entrer votre mot de passe : ");
|
||||
char c;
|
||||
|
||||
for (int i = 0; i < 27; i++) {
|
||||
if (i < 26) {
|
||||
c = getchar();
|
||||
password[i] = c;
|
||||
|
||||
if (c == '\n') {
|
||||
password[i] = '\0';
|
||||
break;
|
||||
}
|
||||
} else if (getchar() != '\n') {
|
||||
printf("Mot de passe trop long !\n");
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
strcat(password, argv[i]);
|
||||
}
|
||||
|
||||
if (strcmp(password, real_password)) {
|
||||
|
||||
if (strcmp(password, real_password) == 0) {
|
||||
puts("Authentification réussie.");
|
||||
} else puts("Mot de passe incorrect.");
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user