diff --git a/a.out b/a.out index 37cf281..9d29128 100755 Binary files a/a.out and b/a.out differ diff --git a/main.c b/main.c index c42e23b..541a78c 100644 --- a/main.c +++ b/main.c @@ -459,7 +459,8 @@ void escolherPerfil(Perfil *p, int counter, int y){ scanf("%d", &x); printf("\n\t\t%s %s | %d anos | %s | %s\n", p[x].nome,p[x].sobrenome, calculateAge(p[x].dataNascimento.dia, p[x].dataNascimento.mes, p[x].dataNascimento.ano), p[x].localidade, p[x].email); - printf("\n\t\t\tMensagens do Mural\n\n"); + printf("\n\t\t\tMensagens do Mural"); + printf("\n\t\t\t------------------\n\n"); if(p[x].contaMsg == 0) { @@ -509,7 +510,8 @@ void publicarMensagem(Perfil *p, int x, int y){ system("clear"); printf("\n\t\t%s %s | %d anos | %s | %s\n", p[x].nome,p[x].sobrenome, calculateAge(p[x].dataNascimento.dia, p[x].dataNascimento.mes, p[x].dataNascimento.ano), p[x].localidade, p[x].email); - printf("\n\t\t\tMensagens do Mural\n\n"); + printf("\n\t\t\tMensagens do Mural"); + printf("\n\t\t\t------------------\n\n"); if(p[x].contaMsg == 0) { diff --git a/notas.txt b/notas.txt deleted file mode 100644 index d24ceb1..0000000 --- a/notas.txt +++ /dev/null @@ -1,34 +0,0 @@ -validação da data, está a eceitar meses > 12 --> OK -validação de string > 1 nas mensagens OK -opção de sair em todos os menus; -- > OK -melhorar apresentação --> OK -adicionar novas funcionalidades -validar data não pode ser superior à data atual --> OK -idade na apresentação do nome/perfil OK - -Exportar 2 perfis para ficheiro OK -Adicionar Localidade à Struct Perfis OK -validar @ no email --> OK -//-------------------------------------------------------- - ---> Carregar Perfis de ficheiro OK ---> Exportar Perfis para o ficheiro OK - ---> Validar Data! OK - ---> Adicionar função de login - - adicionar à struct perfil campos de user e password; OK - - alterar função criar perfil; OK - - tem que validar a password; KO - - tem que camuflar a password; KO - - alterar função listar perfil para incluir login; OK - - depois segue para o menu, tem que levar o ID com ele. OK - - incluir login na função backup e restore; OK - - // Backup e restore -> Pesquisa - https://stackoverflow.com/questions/4368677/writing-an-array-of-structs-to-a-binary-file-in-c - - - - - diff --git a/perfis.txt b/perfis.txt deleted file mode 100644 index 7a0637b..0000000 --- a/perfis.txt +++ /dev/null @@ -1 +0,0 @@ -João 1 Pedro 24 11 1972 exemplo@gmail.com 1 Portalegre 1 jpsaopedro 1 123qwe 1 João 1 Mensagem1 Sandra 1 Reis 25 5 1974 exemplo@gmail.com 1 Fundão 1 sandra 1 123qwe 0 \ No newline at end of file diff --git a/read.c b/read.c deleted file mode 100644 index 218e12c..0000000 --- a/read.c +++ /dev/null @@ -1,29 +0,0 @@ -#include -#include - -struct Person -{ - char f_name[256]; - char l_name[256]; - int age; -}; - -int main() -{ - FILE* data; - if ((data = fopen("data.bin", "rb")) == NULL) - { - printf("Error opening file\n"); - return 1; - } - - struct Person people[2]; - - for (int i = 0; i < 2; i++) { - fread(people, sizeof(struct Person) * 2/* Just read one person */, 1, data); - printf("%s %s\n", people[i].f_name, people[i].l_name); - } - fclose(data); - - return 0; -} \ No newline at end of file diff --git a/teste.c b/teste.c deleted file mode 100644 index 94b9357..0000000 --- a/teste.c +++ /dev/null @@ -1,30 +0,0 @@ -#include - -int menu1() { - - int x; - - printf("(1)\t Opção 1\n"); - printf("(2)\t Opção 2\n"); - printf("\n"); - printf("Escolha uma opção: \n"); - scanf("%d", &x); - - return x; - -} - -int main(){ - - int opcao; - opcao = menu1(); - - if(opcao == 1) { - printf("Foi 1!!\n"); - } else if (opcao == 2) { - printf("Foi 2!!\n"); - } - - - return 0; -} \ No newline at end of file diff --git a/teste2.1.c b/teste2.1.c deleted file mode 100644 index ae893d3..0000000 --- a/teste2.1.c +++ /dev/null @@ -1,27 +0,0 @@ -#include -#include - -int contar[10] = {0}; - -void printContar(){ - - for(int i = 0; i < 10; i++) { - - printf("%d\n", contar[i]); - } -} - -int main(){ - - //printContar(); - - int len; - char str[10]; - //strcpy(str, "João"); - - len = strlen(str); - - printf("%d\n", len); - - return 0; -} \ No newline at end of file diff --git a/teste2.c b/teste2.c deleted file mode 100644 index 9f4bb2c..0000000 --- a/teste2.c +++ /dev/null @@ -1,18 +0,0 @@ -#include - -int contar[10] = {0}; - -void printContar(){ - - for(int i = 0; i < 10; i++) { - - printf("%d\n", contar[i]); - } -} - -int main(){ - - printContar(); - - return 0; -} \ No newline at end of file diff --git a/teste3.c b/teste3.c deleted file mode 100644 index 3db61c3..0000000 --- a/teste3.c +++ /dev/null @@ -1,29 +0,0 @@ -#include -#include -#include - -int contar[10] = {0}; - -void printContar(){ - - for(int i = 0; i < 10; i++) { - - printf("%d\n", contar[i]); - } -} - -int main(){ - - time_t time_raw_format; - struct tm * ptr_time; - - time ( &time_raw_format ); - ptr_time = localtime ( &time_raw_format ); - //printf ("Current local time and date: %s\n", asctime(ptr_time)); - printf("%d-%d-%d\n", ptr_time->tm_mday, ptr_time->tm_mon, ptr_time->tm_year+1900); - - return 0; - - - return 0; -} \ No newline at end of file diff --git a/teste4.c b/teste4.c deleted file mode 100644 index 27491b6..0000000 --- a/teste4.c +++ /dev/null @@ -1,27 +0,0 @@ -#include -#include - -int checkCaracter(char *a, char *b) { - //if a contém b - if (strstr(a, b)) { - - return 1; - } - - return 0; - -} - -int main() { - - char a[20], b[20]; - strcpy(a, "teste@Teste"); - strcpy(b, "este"); - - int res; - - res = checkCaracter(a, b); - printf("%d\n", res); - - return 0; -} \ No newline at end of file diff --git a/teste5.c b/teste5.c deleted file mode 100644 index 8c8187f..0000000 --- a/teste5.c +++ /dev/null @@ -1,57 +0,0 @@ -#include -#include -#include - -typedef struct s_student -{ - char nome[20]; - int idade; - -} Student; - -Student criaStudent(int *a) { - - Student s; - printf("Nome: "); - scanf("%s", s.nome); - printf("Idade: "); - scanf("%d", &s.idade); - - (*a)++; - - return s; - -} - - -int main() { - - int studentCounter = 0; - - Student s[5]; - /* - strcpy(s[1].nome, "João"); - s[1].idade = 29; - strcpy(s[2].nome, "Maria"); - s[2].idade = 14; - */ - - s[studentCounter] = criaStudent(&studentCounter); - s[studentCounter] = criaStudent(&studentCounter); - - - FILE *backup; - backup = fopen("backup.txt", "w"); - - for(int i = 0; i < studentCounter; i++) { - - fprintf(backup, "%s %d", s[i].nome, s[i].idade); - } - - FILE *counter; - counter = fopen("counter.txt", "w"); - - fprintf(counter, "%d", studentCounter); - - return 0; -} diff --git a/teste6.c b/teste6.c deleted file mode 100644 index bdb0cc5..0000000 --- a/teste6.c +++ /dev/null @@ -1,99 +0,0 @@ -#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 diff --git a/teste8.c b/teste8.c deleted file mode 100644 index 76b9a4e..0000000 --- a/teste8.c +++ /dev/null @@ -1,29 +0,0 @@ -#include -#include - -int validaOpcao(int x) { - - int n; - char buffer[10]; - - do - { - printf("Qual a sua opção: "); - fgets(buffer, 10, stdin); - sscanf(buffer, "%d", &n); - - } while (n < 0 || n > x); - - return n; -} - -int main() -{ - int opcao; - - opcao = validaOpcao(3); - printf("%d\n", opcao); - - - return 0; -} \ No newline at end of file diff --git a/teste9.c b/teste9.c deleted file mode 100644 index e5cb3b4..0000000 --- a/teste9.c +++ /dev/null @@ -1,65 +0,0 @@ -#include -#include -#include - -#define MAX_P 3 -#define MAX_C 25 - -typedef struct s_pessoa -{ - char nome[MAX_C]; - char sobrenome[MAX_C]; -} Pessoa; - -Pessoa addPessoa() -{ - - Pessoa p; - - printf("Nome: "); - fgets(p.nome, MAX_C, stdin); - printf("Sobrenome: "); - fgets(p.sobrenome, MAX_C, stdin); - - return p; - -} - -void deletePessoa(int n) -{ - -} - -int main() -{ - - Pessoa p[MAX_P]; - - for (int i; i < MAX_P; i++) - { - p[i] = addPessoa(); - } - - for (int i = 0; i < MAX_P; i++) - { - printf("%d -> %s %s", i, p[i].nome, p[i].sobrenome); - } - - printf("Escolha um perfil para remover: \n"); - int n; - scanf("%d", &n); - - for (int i = n; i < MAX_P; i++) { - - p[i] = p[i+1]; - - } - - for (int i = 0; i < MAX_P; i++) - { - printf("%d -> %s %s", i, p[i].nome, p[i].sobrenome); - } - - - return 0; -} diff --git a/v2.zip b/v2.zip deleted file mode 100644 index 23e6c7a..0000000 Binary files a/v2.zip and /dev/null differ diff --git a/write.c b/write.c deleted file mode 100644 index 89c674e..0000000 --- a/write.c +++ /dev/null @@ -1,53 +0,0 @@ -#include -#include -#include - -#define MAX_L 25 - -struct Person -{ - char f_name[256]; - char l_name[256]; - int age; -}; - -int main() -{ - char buffer[MAX_L]; - - struct Person* people; - int people_count; - - printf("How many people would you like to create: "); - fgets(buffer, MAX_L, stdin); - sscanf(buffer, "%i", &people_count); - people = malloc(sizeof(struct Person) * people_count); - - int n; - for (n = 0; n < people_count; n++) - { - printf("Person %i's First Name: ", n); - fgets(people[n].f_name, MAX_L, stdin); - people[n].f_name[strlen(people[n].f_name)-1] = '\0'; - - printf("Person %i's Last Name: ", n); - fgets(people[n].l_name, MAX_L, stdin); - people[n].l_name[strlen(people[n].l_name)-1] = '\0'; - - printf("Person %i's Age: ", n); - fgets(buffer, MAX_L, stdin); - sscanf(buffer, "%i", &people[n].age); - } - - FILE* data; - if ( (data = fopen("data.bin", "wb")) == NULL ) - { - printf("Error opening file\n"); - return 1; - } - - fwrite(people, sizeof(struct Person) * people_count, 1, data); - fclose(data); - - return 0; -} \ No newline at end of file