Skip to content

Commit

Permalink
v2 update
Browse files Browse the repository at this point in the history
  • Loading branch information
ordepoas committed May 28, 2021
1 parent 4a7302b commit f7855a9
Show file tree
Hide file tree
Showing 4 changed files with 107 additions and 2 deletions.
Binary file modified a.out
Binary file not shown.
9 changes: 7 additions & 2 deletions main.c
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,11 @@ int validaData(int dia, int mes, int ano)
}
}

if(mes > 12 || dia > 31) {

return 0;
}

if ((mes == 4 || mes == 6 || mes == 9 || mes == 11) && (dia > 30)) {

return 0;
Expand Down Expand Up @@ -398,10 +403,10 @@ void listarPerfil(Perfil *p, int counter){

int i;

printf("\t\t--------------------------- [Perfis existentes] ---------------------------\n\n");
printf("\n\t\t------------------- [Escolha um perfil para fazer login] -------------------\n\n");
for(i=0; i < counter; i++) {

printf("\t\t-> %s %s de %s\n", p[i].nome,p[i].sobrenome, p[i].localidade);
printf("\t\t(%d) %s %s de %s\n", i, p[i].nome,p[i].sobrenome, p[i].localidade);

}
printf("\n");
Expand Down
File renamed without changes.
100 changes: 100 additions & 0 deletions teste6.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define MAX_C 20

typedef struct s_pessoa {

char nome[20];
char username [20];
char password [20];

} Pessoa;

int login(Pessoa p) {

char buffer[MAX_C];

char username_aux[MAX_C];
char password_aux[MAX_C];

int valLength, valString, res, c;

printf("----- Login -----\n");
printf("Username: ");
fgets(username_aux, MAX_C, stdin);
username_aux[strlen(username_aux)-1] = '\0';
printf("Password: ");
fgets(password_aux, MAX_C, stdin);
password_aux[strlen(password_aux)-1] = '\0';


if((strlen(username_aux) == strlen(p.username)) && (strlen(password_aux) == strlen(p.password))) {

valLength = 0;

} else {

valLength = 1;
}

if((strstr(p.username, username_aux)) && (strstr(p.password, password_aux))) {

valString = 0;

} else {

valString = 1;
}

res = valLength + valString;

if(res == 0) {

printf("Login efetuado com sucesso!!\n");

} else {

printf("Password e/ou Username errados!!\n");
printf("prima (0) para sair ou (1) para tentar novamente\n");

do {

fgets(buffer, MAX_C, stdin);
sscanf(buffer, "%d", &c);

if(c == 1) {

login(p);

} else {

exit(0);

}

} while (c != 1 || c != 0);

}

return res;

}

int main()
{
Pessoa a;
strcpy(a.nome, "João");
strcpy(a.username, "jpsaopedro");
strcpy(a.password, "qwe123");

Pessoa b;
strcpy(b.nome, "Elsa");
strcpy(b.username, "elsa");
strcpy(b.password, "123qwe");

login(b);

return 0;
}

0 comments on commit f7855a9

Please sign in to comment.