DEV/DEV1.1/TP08/lecture.c

32 lines
499 B
C

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main(void){
char pass[10]= "password1";
int i;
char out;
char string[26];
printf("Rentrez le mot de passe(max 26 charactere): \n");
for(i=0;i<26;i++){
out = getchar();
if(out=='\n'){
break;
}
else{
string[i]=out;
}
}
for(i=0;i<strlen(pass);i++){
if (string[i]!=pass[i])
{
printf("Mauvais mot de passe acces refusé.\n");
return 1;
}
}
printf("Mot de passe correct\n");
return EXIT_SUCCESS;
}