Advertisement
Guest User

main.c

a guest
May 21st, 2011
227
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.48 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include "lista.c"
  4.  
  5. void LeCaracteres (FILE* arquivo, TipoLista *lista)
  6. //Parâmetros: arquivo = arquivo a ser compactado, lista = lista da árvore
  7. //Retorna: nada.
  8. //Ação:
  9. {
  10.     char chaux;
  11.     while(!feof(arquivo))
  12.     {
  13.         fscanf(arquivo, "%c", &chaux);
  14.         if (VerificaCaractere(chaux, lista->primeiro))
  15.         {
  16.            
  17.         }
  18.     }
  19. }//LeCaracteres
  20.  
  21. int VerificaCaractere (char chr, Ponteiro celula)
  22. //Parâmetros: chr = caractere sendo lido, celula = celula a ser checada, quando chamada em outra função deve-se usar a primeira célula da lista
  23. //Retorna: Caractere já existe na lista?  Verdadeiro:Falso
  24. //Ação: verifica a existência de uma célula correspondente a um determinado caracter lido e soma 1 à frequência dela, caso exista(recursivo)
  25. {
  26.  
  27.     if (celula->item.caractere == chr)
  28.     {
  29.         celula->item.frequencia++;
  30.         return 0;
  31.     }
  32.     if (celula->prox != NULL)
  33.     {
  34.         return(VerificaCaractere(chr, celula->prox));
  35.     } else return 1;
  36. }// VerificaCaractere
  37.  
  38. int main()
  39. {
  40.     char adress[100], chaux;
  41.     FILE *filein, *fileout;
  42.     printf("Digite o endereco completo do arquivo a ser compactado.\n");
  43.     gets(adress);
  44.     filein = fopen(adress, "rb");
  45.     fileout = fopen("out.txt", "wb");
  46.     while (!feof(filein))
  47.     {
  48.         fscanf(filein, "%c", &chaux);
  49.         fprintf(fileout,"%c",chaux);
  50.     }
  51.     fclose(filein);
  52.     fclose(fileout);
  53.     return 0;
  54.  
  55. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement