Advertisement
Sam-Sampaio

Acesso

Oct 7th, 2020 (edited)
1,050
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.93 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <string.h>
  4.  
  5. void validate_login(char *l, char *s)
  6. {
  7.      char login[80];
  8.      char senha[80];
  9.      FILE *fp;
  10.  
  11.      if(!(fp = fopen("config.txt", "r")))
  12.      {
  13.          fputs("Erro ao abrir arquivo\n", stdout);
  14.          return;
  15.      }
  16.  
  17.      while(fscanf(fp, "%s%s", login, senha) != EOF)
  18.      {
  19.            if(!strcmp(l, login) && !strcmp(s,senha))
  20.            {
  21.                fputs("\nAcesso liberado\n\n", stdout);
  22.                return;
  23.            } else {
  24.                fputs("\nLogin Incorreto\n\n", stdout);
  25.            }
  26.      }
  27.  
  28. }
  29.  
  30. int main(void)
  31. {
  32.  
  33.     unsigned char login_informado[80] = {0},
  34.                   senha_informado[80] = {0};
  35.  
  36.     fputs("Digite o login: ", stdout);
  37.     scanf("%80s", login_informado);
  38.     fputs("Digite a senha: ", stdout);
  39.     scanf("%80s", senha_informado);
  40.     validate_login(login_informado,senha_informado);
  41.     return 0;
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement