2021-10-12 16:14:21 +02:00
|
|
|
#include<stdio.h>
|
|
|
|
#include<stdlib.h>
|
|
|
|
#include<string.h>
|
|
|
|
|
|
|
|
int main(int argc, char * argv[]) {
|
|
|
|
char real_password[] = "test 1212 34";
|
|
|
|
char password[27];
|
|
|
|
|
2021-10-25 16:38:03 +02:00
|
|
|
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");
|
2021-10-12 16:14:21 +02:00
|
|
|
return EXIT_FAILURE;
|
|
|
|
}
|
|
|
|
}
|
2021-10-25 16:38:03 +02:00
|
|
|
|
|
|
|
if (strcmp(password, real_password) == 0) {
|
2021-10-12 16:14:21 +02:00
|
|
|
puts("Authentification réussie.");
|
|
|
|
} else puts("Mot de passe incorrect.");
|
|
|
|
|
|
|
|
return EXIT_SUCCESS;
|
|
|
|
}
|
|
|
|
|