- #include "genericLL.h"
- #include "genericHash.h"
- #include "lugar.h"
- #include "files.h"
- #include <stdio.h>
- int main() {
- int i=0;
- Hash* hash_lugares;
- FILE *fp, *fpt;
- Lista* lista_aux = (Lista *) malloc(sizeof(Lista));
- Nodo* nodo_aux = (Nodo *) malloc(sizeof(Nodo));
- Lugar* lugar_aux = (Lugar *) malloc(sizeof(Lugar));
- hash_lugares = init_hash();
- if ((fp = fopen("teste.txt", "r")) == NULL)
- fprintf(stderr, "Cannot open %s\n", "teste.txt");
- while(!feof(fp)){
- carrega_lugares(fp,hash_lugares);
- }
- printf("Carreguei a hash\n");
- getchar();
- //fclose(fp);
- for(i=0; i<HASH_SIZE; i++){
- lista_aux = (*hash_lugares)[i];
- if(lista_aux != NULL)
- {nodo_aux = lista_aux -> root;
- lugar_aux = nodo_aux -> dados;
- }
- printf("-----------> iteração i:%d\n\n",i);
- //getchar();
- if(lista_aux == NULL ) printf("posição i = NULL\n\n",i);
- if(lista_aux!=NULL){
- while(nodo_aux != NULL){
- printf("%d:",lugar_aux -> codigo);
- printf("%s:",lugar_aux -> nome);
- printf("%d.",lugar_aux -> latitude.graus);
- printf("%d:",lugar_aux -> latitude.minutos);
- printf("%d.",lugar_aux -> longitude.graus);
- printf("%d:",lugar_aux -> longitude.minutos);
- printf("%d\n",lugar_aux -> pontos_checkin);
- nodo_aux = nodo_aux -> proximo;
- if(nodo_aux != NULL) lugar_aux = nodo_aux -> dados;
- }
- }
- }
- free(lista_aux);
- free(nodo_aux);
- free(lugar_aux);
- if ((fpt = fopen("coord.txt", "w")) == NULL)
- fprintf(stderr, "Cannot open %s\n", "coord.txt");
- /*
- Lugar* lugarteste1 = (Lugar*) malloc(sizeof(Lugar));
- Lugar* lugarteste2 = (Lugar*) malloc(sizeof(Lugar));
- lugarteste2->codigo = 1834;
- strcpy(lugarteste2->nome, "CCISEL - Centro de Cálculo do ISEL");
- lugarteste2->latitude.graus = 38;
- lugarteste2->latitude.minutos = 45;
- lugarteste2->longitude.graus = -9;
- lugarteste2->longitude.minutos = 6;
- lugarteste2->pontos_checkin = 10;
- strcpy(lugarteste2->mayorship.nickname, "Offman");
- lugarteste2->mayorship.pontos = 40;
- lugarteste2->proximo = NULL;
- lugarteste1->codigo = 3;
- strcpy(lugarteste1->nome, "Rendufas do Meio");
- lugarteste1->latitude.graus = 39;
- lugarteste1->latitude.minutos = 33;
- lugarteste1->longitude.graus = -8;
- lugarteste1->longitude.minutos = 31;
- lugarteste1->pontos_checkin = 10;
- strcpy(lugarteste1->mayorship.nickname, "Offman");
- lugarteste1->mayorship.pontos = 40;
- lugarteste1->proximo = lugarteste2;
- */
- printf("bamo guardar");
- getchar();
- guardar_lugares(fpt, hash_lugares);
- fclose(fp);
- fclose(fpt);
- return 1;
- }