#include <stdio.h>
#define max_pasw 5
#define lung_pasw 9
void fine(void);
int main(void)
{
char psw_note[max_pasw][lung_pasw] = {"prima\0",
"seconda\0",
"terza\0",
"quarta\0",
"quinta\0"};
char password[lung_pasw];
char ch;
int i, j;
int accesso = 0;
printf("\n\tQUESTO E' UN SISTEMA AD\n\tACCESSO CONTROLLATO\n\n");
printf("Inserire login: [al piu` %d caratteri]: ", lung_pasw-1);
ch = getchar();
for (i = 0; (i < lung_pasw-1) && (ch != '\n'); i++) {
password[i] = ch;
ch = getchar();
}
password[i] = '\0';
if (ch != '\n') {
scanf("%*[^\n]");
getchar();
}
for (i = 0; (!accesso) && i < max_pasw; i++) {
accesso = 1;
for (j = 0; accesso && password[j] != '\0' && psw_note[i][j] != '\0'; j++)
if (password[j] != psw_note[i][j])
accesso = 0;
accesso = password[j] == '\0' && psw_note[i][j] == '\0';
}
if (accesso)
printf("Login CORRETTA\n");
else
printf("Login NON CORRETTA\n");
fine();
return 0;
}
void fine(void)
{
printf("\ninvio per finire\n");
while (getchar() != '\n');
}