Developpement/23DEV1.1/TPS1/TP01/14-ChainesDeCaractères/lecture.c

29 lines
548 B
C
Raw Permalink Normal View History

2024-12-09 11:53:11 +01:00
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
int main(int argc, char** argv) {
char mdp;
char m1[26] = {'a', 'z', 'e', 'r', 't', 'y', '\0'};
char m2[26];
int identifier;
int i = 0;
int j;
printf("entrez un mot de passe : ");
mdp = getchar();
while(mdp != '\n'){
m2[i] = mdp;
mdp = getchar();
i++;
}
m2[i] = '\0';
identifier = strcmp(m1, m2);
if(identifier == 0){
printf("Mot de passe correct\n");
return EXIT_SUCCESS;
}else{
printf("Mot de passe incorrect\n");
return EXIT_FAILURE;
}
printf("\n");
}