diff --git a/a.out b/a.out index bcacda0..bbe8f68 100755 Binary files a/a.out and b/a.out differ diff --git a/main.c b/main.c index 80de4c5..626f0c1 100644 --- a/main.c +++ b/main.c @@ -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; @@ -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"); diff --git a/teste2copy.c b/teste2.1.c similarity index 100% rename from teste2copy.c rename to teste2.1.c diff --git a/teste6.c b/teste6.c new file mode 100644 index 0000000..314cc0a --- /dev/null +++ b/teste6.c @@ -0,0 +1,100 @@ +#include +#include +#include + +#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; +} \ No newline at end of file